I have a table with fields
1.id-Auto increment
2.name
3.address
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
I have a table with fields
1.id-Auto increment
2.name
3.address
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:
$model->save()
you should be able to get the id via:
$model->id
At least that’s what I would expect (if Qiang implanted this). Try it out
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.