Get Last insert id

Good evening. Appreciate any effort to help me.
I use version 4 and I need to get the last insert id after I save the row in the database from the controller, in previous versions, there was a function
$orderId = $this->Orders->getLastInsertId();
in this version, it gives me a mistake,

Thank you

It will have been added to whatever entity you just saved. But why do you need it? If it’s to add to other related entities, then you can save them all at once and Cake will take care of that for you.

1 Like

if ($articlesTable->save($article)) {
// The $article entity contains the id now
$id = $article->id;
}

taken from:

it is useful,
Thank you very much