2

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

Larry Foobar
  • 11,092
  • 15
  • 56
  • 89

4 Answers4

5

mysql_insert_id();

bensiu
  • 24,660
  • 56
  • 77
  • 117
2

You may find the answer to this StackOverflow question useful:

SQL - INSERT and catch the id auto-increment value

Community
  • 1
  • 1
Tim
  • 1,344
  • 1
  • 11
  • 12
1

mysql_insert_id function returns id of previously inserted record.

I assume you're working with MySQL

Piotr Ratajczak
  • 296
  • 1
  • 3