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:

  1. delete rows outfit_main id = $outfit_id
  2. delete rows outfit_products outfit_id = $outfit_id
  3. 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

Popular posts from this blog

iphone - Three second countdown in cocos2d -

hyperlink - how to do url routing in php -

c - Avoiding Extra Malloc in Linked List (node->next = NULL) -