对于CakePHP版本2.x. 如果$ trs是用户标识的数组,则不必将IN关键字置于条件中.您可以只将数组("Post.user_id"=> $ trs)和Cake添加IN运算符留给此查询.全线:
$ this-> Post-> find('all',array('conditions'=> array('Post.user_id'=> $ trs),'order'=> array('Post.created DESC')));
对于CakePHP版本2.x. 如果$trs1是数组,则不必将IN关键字置于条件中.您可以将just array("Post.user_id" => $trs1)和Cake添加IN运算符添加到此查询中.全线:
$this->Post->find('all',array(
'conditions'=> array('Post.user_id' => $trs1),
'order' => array('Post.id DESC')
));
Run Code Online (Sandbox Code Playgroud)