【发布时间】:2017-01-02 09:24:56
【问题描述】:
在我的事件模型中,我有以下函数来检索状态 = 1 的所有事件,限制为 12,并根据创建的事件 DESC 排序:
public function latestEvents() {
$this->Behaviors->load('Containable');
$result = $this->find('all' ,array('recursive' => -1, 'conditions'=> array('Event.status' => 1), 'limit' => 12, 'order' => array('Event.created DESC')));
debug($result); die();
return $result;
}
此函数不返回任何数据。当我将限制更改为 6 并进行调试时,它会返回六条记录,但是当我将限制更改为超过 6 时,它会返回(空):
我什至通过执行以下查询检查了我的数据库:
SELECT * FROM `events` WHERE `status` = 1 ORDER BY `created` DESC LIMIT 12
这将返回我想要的所需数据。我什至尝试过:
$result = $this->query('SELECT * FROM `events` WHERE `status` = 1 ORDER BY `created` DESC LIMIT 12');
但同样的事情发生在限制上(6 个返回数据,但超过 6 个不返回)。
【问题讨论】:
标签: cakephp-2.x