CodeIgniter-MY_Model icon indicating copy to clipboard operation
CodeIgniter-MY_Model copied to clipboard

Unknown column 'Array' in 'where clause'

Open foxmedo opened this issue 6 years ago • 1 comments

hello im getting database error im trying to update where_id in array

UPDATE `brands` SET `status` = '1', `updated_at` = '2018-11-01 14:32:39' 
WHERE `brands`.`id` IN(Array)

This my controller i have try

$id=$this->input->post('id');

and i have also try

$id= array('2','3');

and this my query

$query = $this->marques_model->where_id($id);
$query = $this->marques_model->update($data);

foxmedo avatar Nov 01 '18 13:11 foxmedo

i have find the cause of problem you have to update my_model change

$this->_database->{$where_or.$not.'_in'}($this->table.'.'.$field_or_array, $operator_or_value);

by

$multi = $this->is_multidimensional($operator_or_value);
            if($multi){
                foreach($operator_or_value as $row_value){
                    $this->_database->{$where_or.$not.'_in'}($this->table.'.'.$field_or_array, $row_value);
                }
            }else{
                $this->_database->{$where_or.$not.'_in'}($this->table.'.'.$field_or_array, $operator_or_value);
            }

foxmedo avatar Nov 01 '18 15:11 foxmedo