2 回答
TA贡献1860条经验 获得超9个赞
将关联的数组值获取到单个数组中,然后将其传递给查询
$assoicative_array = array(array(10,20,30));
$ids=array();
foreach($assoicative_array as $key =>$value ){
$ids[]=$value;
}
$this->db->where_in('userId',$ids);
$this->db->where_in('customer_id',$ids);
$this->db->delete('table');
die(var_dump($this->db->last_query()));
TA贡献1934条经验 获得超2个赞
这是我尝试过的并且有效:
foreach ( $data as $row )
{
$userIds[] = $row['userId'];
$customerIds[] = $row['customerId'];
}
$this->db->where_in('userId', $userIds);
$this->db->where_in('customer_id', $customerIds);
$this->db->delete('table');
这将删除行,生成的查询是:
DELETE FROM `table`
WHERE `userId` IN('10', '11', '54')
AND `customer_id` IN('1809', '1904', '201')
- 2 回答
- 0 关注
- 76 浏览
添加回答
举报