After deleting a row. how to get its id.
we can receive inserted ID from $this->db->insert_id(). Is there similar function for getting deleted records id.
After deleting a row. how to get its id.
we can receive inserted ID from $this->db->insert_id(). Is there similar function for getting deleted records id.
However you will the id to delete a record.
In model, you will pass id as parameter. try below code.
public function delete_row($id)
{
$this->db->where(array("id"=>$id));
$this->db->delete("my_table");
if($this->db->affected_rows()>0)
return $id;
else
return false;
}
Note: If you didn't pass id. then you have to use same parameters which are used to delete to get the record before deleting the record.
You should first save the id you are about to delete in a variable then after passing the variable(id) to the query and the row is deleted you will be able to do whatever you want with the id that is still stored in the the variable. simple and straight forward no functions added needed.