How to get the last inserted ID

QuestionsHow to get the last inserted ID
Roy asked 5 years ago

I see that this will get the last inserted ID:

$e["on_after_insert"] = array("after_insert", null, true); // return last inserted id for further working

but I don't see and docs on how to reference this ID in my function

e.g.

function after_insert($data)
{
$LastInsertedID = (what?)
}

Can you explain how to get the last inserted ID?

thanks

Roy.

2 Answers
Abu Ghufran answered 5 years ago

You can print_r($data) and check output in firebug insert call response.

It's usually $data["<first-column-name>"]

Roy answered 5 years ago

Thanks.

That pointed me in the right direction.

Roy.

Your Answer

17 + 11 =

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating / 5. Vote count:

As you found this post useful...

Follow us on social media!

We are sorry that this post was not useful for you!

Let us improve this post!