0

i have display error like this 1292 Truncated incorrect DOUBLE value this is my delete operation function code in code igniter model

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

and its display error

Error Number: 1292
Truncated incorrect DOUBLE value: '305,304'
DELETE FROM student_marks WHERE student_id NOT IN ('305,304')

because of in this portion '305,304' single quota ' ' auto added so its display 1292 error how to i fix it?

M. Eriksson
  • 13,450
  • 4
  • 29
  • 40
pranay
  • 49
  • 9

2 Answers2

3

It looks like your $s_id is string. In CI, where_not_in or where_in you have to pass array.

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');
}
B. Desai
  • 16,414
  • 5
  • 26
  • 47
1

In where_not_in you have to pass an array.

public function delete_marks($s_id){
    $this->db->where_not_in('student_id',explode(',', $s_id));
    return  $this->db->delete('student_marks');
}
Pradeep
  • 9,667
  • 13
  • 27
  • 34