Can anyone help me to do this in the right way?I mean.. like that : $db->select()->group….. I tried a few times, but doesn’t work for me 🙁
$this->q->fetchAll(‘select * from clubs, club_photos_default where clubs.id=club_photos_default.c_id group by clubs.id’);
Best Regards,
The right way in this case is the way you’re doing it, since the whole SQL query is known and static.
You are not required to use
Zend_Db_Selectto build queries procedurally. In fact, it’s often more complex and less readable than just typing out the literal SQL query.Use
Zend_Db_Selectwhen you need to build a query procedurally, based on variables and logic in your application code.But to answer your question, this should work:
(Assuming
$dbis an object ofZend_Db_Adapter.)