How do I get the autoincremented ID of the latest inserted row. - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: Model-View-Controller (https://forum.codeigniter.com/forumdisplay.php?fid=10) +--- Thread: How do I get the autoincremented ID of the latest inserted row. (/showthread.php?tid=84146) |
How do I get the autoincremented ID of the latest inserted row. - davecoventry - 10-15-2022 My code: PHP Code: $this->db->simpleQuery('Use D'.$id); This returns a model object, but I need the number of the ID. if I use PHP Code: $this->db->insert_id(); I get an error which says that insert_id() is an undefined method. Code: +----------+--------------+------+-----+---------------------+----------------+ RE: How do I get the autoincremented ID of the latest inserted row. - JustJohnQ - 10-15-2022 PHP Code: $this->db->insertID() RE: How do I get the autoincremented ID of the latest inserted row. - davecoventry - 10-16-2022 It's suddenly started working for me too. I have no idea what I was doing wrong, but it was obviously something stupid. Thanks for your response, and sorry to have wasted everybody's time (including my own!). |