Model return id record |
What are the ways to return the id of the created record in the table?
PHP Code: public function insertAny($title, $slug) { Because I have only one idea, this is to create an additional unique field on which, after executing the record, perform a search and return the ID. But I think there should be some solution out of the CI box. P.S Thank for your attention!
CodeIgniter 4 User Guide - Query Helper Methods
PHP Code: $db->insertID() What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
What @InsiteFX said. Also if you do your insert through a Model you can use the method `getInsertID()` that will return the last insert handle *by that model*. This can also be returned directly from the insert statement using the second parameter: `$insertID = $model->insert($row, true)`
|
Welcome Guest, Not a member yet? Register Sign In |