Reputation: 11
My client website using Zendframework. Now they ask me to random the result. I using RAND() but not working. Anybody can help?
Here is the code (the RAND() at the bottom)
$oPlaceSelect = $oPlaces->select()->setIntegrityCheck(false)
->from(array('p' => 'places'),
array('id', 'place_title' => 'title', 'alias', 'categories_id',
=> '(SELECT path FROM places_images WHERE places_images.places_id = p.id group by places_id)'))
->order('RAND()');
Thanks,
Upvotes: 1
Views: 606
Reputation: 14882
To use mysql function in a Zend Select object, you need to use 'Zend_Db_Expr'
->order(new Zend_Db_Expr("RAND()"));
Upvotes: 4