Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/86.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Cakephp中使用IN运算符_Php_Sql_Cakephp - Fatal编程技术网

如何在Cakephp中使用IN运算符

如何在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

对于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->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也有效。您的编辑实际上会使问题变得更糟。不是更好。