【发布时间】:2011-03-11 06:23:25
【问题描述】:
尝试从模型中获取单个随机行。这是我从网上提取的:
$this->Testimonial->findAll(null,null,'rand()',1,null,null);
很遗憾 findAll 在 cakephp 1.3 中不再存在
【问题讨论】:
标签: cakephp-1.3
尝试从模型中获取单个随机行。这是我从网上提取的:
$this->Testimonial->findAll(null,null,'rand()',1,null,null);
很遗憾 findAll 在 cakephp 1.3 中不再存在
【问题讨论】:
标签: cakephp-1.3
$this->Quote->find('first', array('order' => array('rand()')))
【讨论】:
你可以试试这个:
$count = $this->Testimonial->find('count');
$this->Testimonial->find('first', array('conditions' => array('id' => rand(1,$count))));
(这也不会检索“所有”结果)
【讨论】:
$find = $this->Model->find('all'); echo $find[rand(0,count($find))]['Model']['someName']