Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/284.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.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
Php 如何在CodeIgniter中将数组传递到何处条件?_Php_Mysql_Codeigniter - Fatal编程技术网

Php 如何在CodeIgniter中将数组传递到何处条件?

Php 如何在CodeIgniter中将数组传递到何处条件?,php,mysql,codeigniter,Php,Mysql,Codeigniter,我正在应用程序中使用CodeIgniter。我有这样的代码 $this->db->where('a.PreferenceID不在(选择PreferenceParentID 来自“$table.”,其中EntityID=“$shop_id.”),NULL,FALSE) 我想传递一个数组,而不是$shop\u id 像 等于 WHERE (EntityID='. $arr[0].' OR EntityID='. $arr[1].' OR EntityID='. $arr[2].') 因为我想检查多

我正在应用程序中使用
CodeIgniter
。我有这样的代码

$this->db->where('a.PreferenceID不在(选择PreferenceParentID 来自“$table.”,其中EntityID=“$shop_id.”),NULL,FALSE)

我想传递一个
数组,而不是
$shop\u id

等于

WHERE (EntityID='. $arr[0].' OR EntityID='. $arr[1].' OR EntityID='. $arr[2].')
因为我想检查多个店铺id。最好的方法是什么?

使用

'SELECT PreferenceParentID FROM '.$table.' WHERE EntityID IN ('.implode(',', $arr_id).')'
使用


子句中使用
,如

$this->db->where('a.PreferenceID NOT IN (
    SELECT PreferenceParentID FROM '.$table.' 
    WHERE EntityID IN ('.implode(",", $array).'))',
    NULL, FALSE
);

子句中使用
,如

$this->db->where('a.PreferenceID NOT IN (
    SELECT PreferenceParentID FROM '.$table.' 
    WHERE EntityID IN ('.implode(",", $array).'))',
    NULL, FALSE
);
试试像这样的东西

WHERE EntityID IN('.implode(',', $arr).')
试试像这样的东西

WHERE EntityID IN('.implode(',', $arr).')