Cakephp 2.x 无法从查找查询中检索数据
在我的事件模型中,我有以下函数根据创建的事件描述检索状态为1、限制为12、顺序为12的所有事件:Cakephp 2.x 无法从查找查询中检索数据,cakephp-2.x,Cakephp 2.x,在我的事件模型中,我有以下函数根据创建的事件描述检索状态为1、限制为12、顺序为12的所有事件: public function latestEvents() { $this->Behaviors->load('Containable'); $result = $this->find('all' ,array('recursive' => -1, 'conditions'=> array('Event.status' => 1), 'limit
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条记录,但当我将限制更改为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不返回数据)。我发现我试图调试的数据具有特殊字符,我必须在我的database.php中包含
'encoding'=>'utf8'
,并且工作得非常出色。这对我有帮助