I am able to get the last inserted id using $this->db->insert_id();
in codeigniter, is there any way that I can get the id of the last updated record? I tried
Using a codeigniter , and MY_MODEL an extend version.This was one of the bottlneck this how i got a relfe.
function update_by($where = array(),$data=array())
{
$this->db->where($where);
$query = $this->db->update($this->_table,$data);
return $this->db->get($this->_table)->row()->id; //id must be exactly the name of your table primary key
}
call this Updates plus get the updated id. kinda overkill to run a query twice i guess but so do all the aboves.
how you call ?
$where = array('ABC_id'=>5,'DEF_ID'=>6);
$data = array('status'=>'ACCEPT','seen_status' =>'SEEN');
$updated_id= $this->friends->update_by($where,$data);