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

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -

php - Accessing static methods using newly created $obj or using class Name -