Trying to get a single random row from a model. I pulled this from the web:
$this->Testimonial->findAll(null,null,'rand()',1,null,null);
Unfortunately findAll doesn't exist anymore in cakephp 1.3
$this->Quote->find('first', array('order' => array('rand()')))
you can try this:
$count = $this->Testimonial->find('count');
$this->Testimonial->find('first', array('conditions' => array('id' => rand(1,$count))));
(this also doesn't retrieve "all" the results)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With