Need to find some value of the last saved record in table

I have a table with fields increment


whenever i store a record i need the id of the record as soon as it gets saved is there any of finding it without using findAll

as soon as you save the model:


you should be able to get the id via:


At least that’s what I would expect (if Qiang implanted this). Try it out

lastInsertID could do this:

From the docs:

If the record is being inserted and its primary key is null,

after insertion the primary key will be populated with the value

generated automatically by the database.

Presuming id is the PK, then you are done by saving.

This is normal, because it is common to use a PK from a record to use while populating other tables.