Reputation: 10033
I'm using Zend framework and trying to get the results to be in a random order. This returns the results but doesn't seem to vary the order. Any ideas?
class Model_DBTable_Tblquotes extends Zend_Db_Table
{
public function getQuotes()
{
$select = $this->select();
$select->setIntegrityCheck(false)
->from('tblQuotes',array('id','quote','author','dateCreated'))
->order(new Zend_Db_Expr('RAND()'))
->limit(25, 0);
return $this->fetchAll($select);
}
}
Upvotes: 2
Views: 107
Reputation: 19
you need to pass in the expression as a string: "RANDOM()"
example: ->order(new Zend_Db_Expr('RANDOM()'));
Upvotes: 0
Reputation: 12853
Have you tried
->order('RAND()')
instead of
->order(new Zend_Db_Expr('RAND()'))
You can also use
$select->__toString();
On your db obj to get a string of the query so you could echo it and look at it to see whats wrong.
Upvotes: 1