错误号:1292在我的SQL错误中截断了错误的DOUBLE值

时间:2018-04-20 11:48:24

标签: php mysql codeigniter mysqli

我有这样的显示错误1292截断不正确的DOUBLE值  这是我在代码点火器模型中的删除操作功能代码

public function delete_marks($s_id){
           $this->db->where_not_in('student_id', $s_id);
           return  $this->db->delete('student_marks');
       }

及其显示错误

  

错误号码:1292
  截断不正确的DOUBLE值:' 305,304'
  DELETE FROM student_marks WHERE student_id NOT IN(' 305,304')

因为此部分'305,304'单个配额' '自动添加 所以它显示1292错误 我该怎么解决?

2 个答案:

答案 0 :(得分:3)

看起来你的$s_id是字符串。在CI中,where_not_inwhere_in您必须传递数组。

public function delete_marks($s_id){
    $s_id = explode(",", $s_id);
    $this->db->where_not_in('student_id', $s_id);
    return  $this->db->delete('student_marks');
}

答案 1 :(得分:1)

where_not_in中你必须传递数组。

public function delete_marks($s_id){
    $this->db->where_not_in('student_id',explode(',', $s_id));
    return  $this->db->delete('student_marks');
}