如何才能让随机结果仅在24小时后发生变化?
$random = $this->Post->find('first',array(
'conditions' => array(
'Post.active'=>1,
),
'order' => 'rand()',
));
$this->view($random['Post']['id']);
$this->render('view');
答案 0 :(得分:0)
您可以尝试根据当前日期为rand()
函数使用种子。
$random = $this->Post->find('first', array(
'conditions' => array(
'Post.active' => 1,
),
'order' => 'rand(' . date('Ymd') . ')',
));
或者,缓存结果并每天刷新一次缓存。