How to return one random line from the model?

Trying to get one random string from a model. I pulled this from the internet:

$this->Testimonial->findAll(null,null,'rand()',1,null,null);

Unfortunately findAll no longer exists in cakephp 1.3

+3
source share
2 answers
$this->Quote->find('first', array('order' => array('rand()')))
+7
source

you can try the following:

$count = $this->Testimonial->find('count');
$this->Testimonial->find('first', array('conditions' => array('id' => rand(1,$count))));

(this also does not return "all" results)

+2
source

All Articles