如何在Cakephp中使用IN运算符
对于CakePHP 2.x版。如果$trs是一个用户id数组,则不必在条件中输入关键字。您只需将arrayPost.user_id=>$trs和Cake加载项运算符保留在此查询中即可。全线:如何在Cakephp中使用IN运算符,php,sql,cakephp,Php,Sql,Cakephp,对于CakePHP 2.x版。如果$trs是一个用户id数组,则不必在条件中输入关键字。您只需将arrayPost.user_id=>$trs和Cake加载项运算符保留在此查询中即可。全线: $this->Post->find('all',array( 'conditions'=> array('Post.user_id' => $trs1), 'order' => array('Post.id DESC') )); $this->Post->f
$this->Post->find('all',array(
'conditions'=> array('Post.user_id' => $trs1),
'order' => array('Post.id DESC')
));
$this->Post->find'all',array'conditions'=>array'Post.user\u id'=>$trs,
'order'=>数组'Post.created DESC' 适用于CakePHP 2.x版。如果$trs1是一个数组,则不必在条件中输入关键字。您只需将arrayPost.user_id=>$trs1和Cake加载项运算符保留在此查询中即可。全线:
$this->Post->find('all',array(
'conditions'=> array('Post.user_id' => $trs1),
'order' => array('Post.id DESC')
));
请注意,这只对2.x有效-在CakePHP 3.x中,您必须添加。哦,谢谢,我还没有看过3.x版本。对cake 1.3也有效。您的编辑实际上会使问题变得更糟。不是更好。