avenirer / CodeIgniter-MY_Model

Base model (MY_Model) for the Codeigniter framework.
324 stars 203 forks source link

Unknown column 'Array' in 'where clause' #279

Open foxmedo opened 6 years ago

foxmedo commented 6 years ago

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 commented 6 years ago

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);
            }