I'm programming in a button to allow users to add a new category or article but I'm also tracking the IDs to create the custom webpage structure.

So when the user clicks the button I need to know the ID that was just created. I haven't found the documentation that says how to capture that. Can someone point me in the right direction?

I could look up the last ID created but if multiple users are creating articles or categories at the same time that method probably is not going to work.



1 Answer 1


There is a relevant discussion here, but in short it just concludes that using the jdatabase insertid method is just as rubbish as mysqli_insert_id.

Joomla DB Insert, how to get last inserted id?

The trick is to do a select using fields that you already have from the insert query, eg. get max id & match the userid, or any other fields that you might have, and include the selected id in the response.

  • Thanks. Was hoping for a more streamlined method but I'll have to stick with what you suggest.
    – joecap5
    Commented Aug 12, 2017 at 11:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.