简体   繁体   中英

How to get id of just-executed sql query (in php)

In php I have an INSERT query to database. This query add some issue to database. I want to check if issue was added fine (there are some cases when issue doesn't added - without any mistake reporting). How to check this?

I have an idea, that after i make INSERT query i should make a query, for example: SELECT ..... WHERE id=last_id . But how to get the last_id - how to get id of last INSERT query? (id is autoincrementing sql field)

Thank you

You may find the answer to this StackOverflow question useful:

SQL - INSERT and catch the id auto-increment value

mysql_insert_id function returns id of previously inserted record.

I assume you're working with MySQL

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM