cakephp 查找方法不起作用

cakephp find method not working

我知道这是一个非常愚蠢的问题,但在这里我没有收到任何错误。

波纹管查询工作正常

$data=$this->Test->query('SELECT * FROM tests where report_id=85');

但是 find 方法中的相同查询不起作用

$condition=array('Test.report_id'=>85);
$data=$this->Test->find('all',array('condition'=>$condition));

find cakephp中的语句应该是

$condition=array('Test.report_id'=>85);
$data = $this->Test->find('all',array('conditions'=>$condition));
Cakephp find statement error in 'codintion' 
You should try this
$data=$this->Test->find('all',
  array('conditions'=>
  array('Test.report_id'=>85)
 )
);

please replace condition to conditions

你做了 Typo.And 让我们明白为什么要使用 's'。

一个数组可以有100个条件,不能只有一个,所以它conditions

$conditions=array('Test.report_id'=>85);
$data = $this->Test->find('all',array('conditions'=>$conditions));

还有一件事 -> 始终使用 $conditions 作为变量命名约定,因为您永远不知道有 1,2 或 1000 个条件。