A little bit of code-snippet:
$this->db->where('id', $outfit_id);
$this->db->update('outfit_main',$data);
//Delete productsettings for specific outfit (They are added below with new values)
$this->db->where('outfit_id', $outfit_id);
$this->db->delete('outfit_products');
//Delete outfit_images for specific outfit as well. They are also added below
$this->db->where('outfit_id', $outfit_id);
$this->db->delete('outfit_images');
What I want to do is:
But in fact when I add the last two rows:
$this->db->where('outfit_id', $outfit_id);
$this->db->delete('outfit_images');
*it deletes all rows from outfit_main as well. why?*
Try combining the where clause with the 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));
it seems that, Ci
is using old/cached
query for where
clauses, so if you flush
to clear the cache using
$this->db->flush_cache();
And then use
$this->db->where('outfit_id', $outfit_id);
$this->db->delete('outfit_images');
Then, maybe it'll work in right way. Check caching examples, it'll be more clear and I've confusion about it as well, so waiting for response.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With