I have the following php code to insert data to the table
$fields=$this->db->list_fields('branddistribution_products');
foreach($data as $key=>$v){
if(!in_array($key, $fields)){
unset($data[$key]);
}
}
$this->db->where('product_id', $data['product_id']);
$this->db->from('branddistribution_products');
$count = $this->db->count_all_results();
if($count==0){
$this->db->insert('branddistribution_products', $data);
}else{
$this->db->update('branddistribution_products', $data);
}
and $data
is an array which have picture 1
picture 2
picture 3
key indexes.But when I insert to the db the key index change to 'picture' 1, 'picture' 2, 'picture' 3
.I have DB table column same as that indexes.The following database error arise
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1, `picture` 2, `picture` 3, `madein`, `Firme`, `heel`, `lenght`, `mainmaterial`' at line 1
How can I skip this index changes.