PHP / mysqli how to find out about newly inserted ID

I have a simple table containing a primary key with an Auto Increment index.

When I insert mysqli, is it possible to find out the last inserted value of the Auto Increment column?

Note:

There may be several people trying to insert at the same time

+3
source share
5 answers

You can simply use: mysqli_insert_id($con)

+10
source

You can use the insert_id value (rather than the method call) from the database object :)

$id = $db->insert_id;
+5
source

, "$ link", $link - , mysqli_connect() mysqli_init():

$last_id = mysqli_insert_id($link);

+2
   $last_id = $link->insert_id;

$link - MySQLi.

:

$last_id = mysqli_insert_id();
+1

All Articles