Different Types of Delete Queries in Codeigniter

In Codeigniter we have Four Types of Queries to Delete data in database


$this->db->delete('tbl_user', array('id' => $id)); 
//DELETE FROM tbl_user WHERE id = $id

$this->db->where('id', $id);
//DELETE FROM tbl_user WHERE id = $id
An array of table names can be passed into delete() if you would like to delete data from more than 1 table.

$tables = array('table1', 'table2', 'table3');
$this->db->where('id', $id);


// DELETE FROM tbl_user


// TRUNCATE table tbl_user;

Delete With Join

$this->db->join("table2", "table1.t1_id = table2.t2_id");
$this->db->where("table2.t2_id", $id);