How to get the last Inserted ID after insert data using the query builder ? |
Hello !
Does anyone knows how to get the last Inserted ID after insert data using the query builder class? In CI 3 I just used: PHP Code: $this->db->insert_id(); What would be the equivalent in CI 4 ? PHP Code: public function insertNewCandidate($candidate) { And YES, I do want to use query builder for this... I tried to find it in $db, $builder and $query... But it is not there.... (10-05-2019, 07:44 PM)donpwinston Wrote: Did you try: This worked: PHP Code: return $db->insertID(); The problem is that when you search the User Guide for "insert id" or "insert_id" it returns 0 results.... That is why I couldn´t find it. But it is there: https://codeigniter4.github.io/userguide...lpers.html Thank you ! ![]()
Working With Databases - Query Helper Functions
What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
|
Welcome Guest, Not a member yet? Register Sign In |