Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

gust's avatar
Level 1

How to retrieve the id of a row I just saved?

I just saved a quiz object into table quizzes via

$quiz->save()

Now I need to access its id, what would be the best way to do this?

0 likes
3 replies
gust's avatar
Level 1

oh interesting so the quiz object originally had the generated id, it wasn't generated once after/once it was saved on the table?

SaeedPrez's avatar

It is added after it is saved, because the id comes from the database.

Please or to participate in this conversation.