ZF2-424: Sql query builder doesn't support distinct
Description
The Sql object query builder doesn't support the distinct keyword, which was available in ZF1.
The Sql object query builder doesn't support the distinct keyword, which was available in ZF1.
Comments
Posted by Ralph Schindler (ralph) on 2012-07-26T15:59:45.000+0000
It does indeed, you can pass an expression as a column name ($select is an instance of Zend\Db\Sql\Select)
If you have to ensure that the column is properly quoted for future abstraction purposes:
Posted by Ken Lynch (nyorai) on 2012-07-27T07:58:15.000+0000
This doesn't feel very obvious and causes an error if the distinct expression doesn't come first (certainly using MySQL). How can I take a base select query and later in another method add a join and make it return distinct rows? In my specific case I have a base query that selects orders, I might modify this with a join against the order items when I want to only select orders that have a certain item. In ZF1 you would simply do the join and call the distinct method.
Posted by Ralph Schindler (ralph) on 2012-07-27T14:24:07.000+0000
You make an excellent point. I'll work on this soon.
Posted by Ralph Schindler (ralph) on 2012-10-08T20:15:05.000+0000
This issue has been closed on Jira and moved to GitHub for issue tracking. To continue following the resolution of this issues, please visit: https://github.com/zendframework/zf2/issues/2509