![]() |
Getting the last database identifier - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Getting the last database identifier (/showthread.php?tid=5739) |
Getting the last database identifier - El Forum - 02-02-2008 [eluser]bikuta[/eluser] Hi, I was wondering whether it was possible with active query to get the last id that was generated after a new record has been entered into the database. So basically I've got something like this: $this->obj_model->add($data); // need to get unique id from previous command to update a value in $otherdata $this->otherobj_model->add($otherdata); the add() methods just calls a $this->db->insert command. Getting the last database identifier - El Forum - 02-02-2008 [eluser]LuckyFella73[/eluser] Have a look at the user guide: http://ellislab.com/codeigniter/user-guide/database/helpers.html should be: Code: $this->db->insert_id() Getting the last database identifier - El Forum - 02-02-2008 [eluser]bikuta[/eluser] cool thanks so would I just call that once I've called the first add() method? |