Group By on 2 fields on Zend_Db

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Group By on 2 fields on Zend_Db

Cristian Bichis-4
Hi,

Anyone knows how to create a Group By on 2 fields on ZF1?

Seems no matter what I pass to ->group, either a array with this 2
fields or a string as "field1,field2" only one field is taken into
consideration....

Cristian
Reply | Threaded
Open this post in threaded view
|

Re: Group By on 2 fields on Zend_Db

cmple
This post has NOT been accepted by the mailing list yet.
Cristian Bichis-4 wrote
Hi,

Anyone knows how to create a Group By on 2 fields on ZF1?

Seems no matter what I pass to ->group, either a array with this 2
fields or a string as "field1,field2" only one field is taken into
consideration....

Cristian
Have you tried passing an Expression?
->group(new Expression('field1,field2'));
Reply | Threaded
Open this post in threaded view
|

Re: Group By on 2 fields on Zend_Db

samsonasik
This post has NOT been accepted by the mailing list yet.
In reply to this post by Cristian Bichis-4
Try :
use Zend\Db\Sql\Select;  

........
    $resultSet = $this->select(function (Select $select){
                $select->group(array('email', 'name', 'gender'));
    });