Wednesday, 28 August 2013

PHP delete from database with codeigniter

PHP delete from database with codeigniter

I want to delete an entry in one table of my database. The table name is
book. But in table title use foreign key book.
book: id, name
title: id, book_id, title
Now I want to delete an entry in book. So, I have to delete related
entries in title table. My code is :
$this->db->where(book_id,$deleteid);
$this->db->delete(title);
$this->db->where(id,$deleteid);
$this->db->delete(book);
My question is whether the first where clause will affect my second delete
clause? If it affects the second one, what should I do to avoid this?
Thanks. I am a beginner of PHP.

No comments:

Post a Comment