php - Delete rows from different tables in CodeIgniter -
a little bit of code-snippet:
$this->db->where('id', $outfit_id); $this->db->update('outfit_main',$data); //delete productsettings specific outfit (they added below new values) $this->db->where('outfit_id', $outfit_id); $this->db->delete('outfit_products'); //delete outfit_images specific outfit well. added below $this->db->where('outfit_id', $outfit_id); $this->db->delete('outfit_images');
what want is:
- delete rows outfit_main id = $outfit_id
- delete rows outfit_products outfit_id = $outfit_id
- delete rows outfit_images outfit_id = $outfit_id
but in fact when add last 2 rows:
$this->db->where('outfit_id', $outfit_id); $this->db->delete('outfit_images');
*it deletes rows outfit_main well. why?*
try combining clause delete active record:
$this->db->delete('outfit_main', array('id' => $outfit_id)); $this->db->delete('outfit_products', array('outfit_id' => $outfit_id)); $this->db->delete('outfit_images', array('outfit_id' => $outfit_id));
Comments
Post a Comment