Hot to get ID of record inserted using model "save()" method |
save() doesn't return the ID but insert() does (comment in Model.php actually notes "call insert directly if you want the ID or the record object"). If you must use save you can use the query helper method "$db->insertID()"
https://codeigniter4.github.io/userguide...lpers.html Oops, just read your final comment! You should be able to access $model->db because the model class has a magic __get() method to pass through. |
Messages In This Thread |
Hot to get ID of record inserted using model "save()" method - by RobT - 11-20-2019, 08:58 AM
RE: Hot to get ID of record inserted using model "save()" method - by MGatner - 11-20-2019, 09:53 AM
RE: Hot to get ID of record inserted using model "save()" method - by RobT - 11-20-2019, 10:11 AM
RE: Hot to get ID of record inserted using model "save()" method - by MGatner - 11-20-2019, 12:46 PM
|