我正在使用 CodeIgniter,并且我的 Controller 中有两个变量
$bus_code = 1;
$route_code = array('route_code' => 1,'route_code' => 3,'route_code' => 4);
mysql表数据,
- id, route_code, bus_code
- 1, 1, 1
- 2, 2, 2
- 3, 3, 1
- 4, 4, 1
- 5, 5, 2
- 6, 7, 2
我想删除总线代码为 1 且路线代码不在 $route_code
数组中的数据
在CodeIgniter模型中
最佳答案
给你。
$this->db->where('bus_code', $id);
$this->db->where_not_in('route_code', $route_code);
$this->db->delete('tableName');
关于php - 从数据库中删除 php 数组中不存在的数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50792273/