CodeIgniter活动记录不在字符串中

JRE*_*EAM 14 codeigniter

我在CI Active Record的" Where Not In "中遇到了问题.我试图排除一系列ID.我无法理解为什么一切都运行良好,花花公子一个记录,但没有多个.

我的查询

$this->db->where_not_in('crm.user_id', $ignore);
Run Code Online (Sandbox Code Playgroud)

问题是当我分析查询是错误的时候.

带有一串ID

// $ignore = "12,13";    
SELECT *
FROM (`crm`)
WHERE `crm`.`user_id` NOT IN ('16,13') 
AND `survey` =  1 
Run Code Online (Sandbox Code Playgroud)

带有一串引号ID

// $ignore = "'12','13'";
SELECT *
FROM (`crm`)
WHERE `crm`.`user_id` NOT IN ('\'16\',\'13\'') 
AND `survey` =  1 
Run Code Online (Sandbox Code Playgroud)

我被迫做了一个" or_where_not_in "或类似的循环吗?

Roc*_*mat 37

where_inwhere_not_in期望您传递一个数组,而不是一个字符串作为第二个参数.

$ignore = array(12, 13);

$this->db->where_not_in('crm.user_id', $ignore);
Run Code Online (Sandbox Code Playgroud)

链接到文档:http://www.codeigniter.com/userguide2/database/active_record.html