diff --git a/reference/mysqli/mysqli/insert-id.xml b/reference/mysqli/mysqli/insert-id.xml
index 97eb53b38b..fd5e5ec232 100644
--- a/reference/mysqli/mysqli/insert-id.xml
+++ b/reference/mysqli/mysqli/insert-id.xml
@@ -4,7 +4,7 @@
mysqli::$insert_id
mysqli_insert_id
- Returns the auto generated id used in the latest query
+ Returns the value generated for an AUTO_INCREMENT column by the last query
@@ -17,19 +17,25 @@
mysqlimysql
- The mysqli_insert_id function returns the ID generated
- by a query (usually INSERT) on a table with a column having the
- AUTO_INCREMENT attribute. If no INSERT or UPDATE statements were sent via this
-connection, or if the modified table does not have a column
- with the AUTO_INCREMENT attribute, this function will return zero.
+ Returns the ID generated by an INSERT or
+ UPDATE query on a table with a column having the
+ AUTO_INCREMENT attribute. In the case of a multiple-row
+ INSERT statement, it returns the first automatically
+ generated value that was successfully inserted.
+
+
+ Performing an INSERT or UPDATE
+ statement using the LAST_INSERT_ID()
+ MySQL function will also modify the value returned by mysqli_insert_id.
+ If LAST_INSERT_ID(expr) was used to generate the value of
+ AUTO_INCREMENT, it returns the value of the last expr
+ instead of the generated AUTO_INCREMENT value.
+
+
+ Returns 0 if the previous statement did not change an
+ AUTO_INCREMENT value. mysqli_insert_id must be
+ called immediately after the statement that generated the value.
-
-
- Performing an INSERT or UPDATE statement using the LAST_INSERT_ID()
- function will also modify the value returned by the
- mysqli_insert_id function.
-
-
@@ -49,10 +55,14 @@ connection, or if the modified table does not have a column
connection or if the query did not update an AUTO_INCREMENT
value.
+
+ Only statements issued using the current connection affect the return value. The
+ value is not affected by statements issued using other connections or clients.
+
- If the number is greater than maximal int value, mysqli_insert_id
- will return a string.
+ If the number is greater than the maximum int value, it will be returned as
+ a string.
@@ -65,60 +75,44 @@ connection, or if the modified table does not have a column
query("CREATE TABLE myCity LIKE City");
$query = "INSERT INTO myCity VALUES (NULL, 'Stuttgart', 'DEU', 'Stuttgart', 617000)";
$mysqli->query($query);
-printf ("New Record has id %d.\n", $mysqli->insert_id);
+printf("New record has ID %d.\n", $mysqli->insert_id);
/* drop table */
$mysqli->query("DROP TABLE myCity");
-
-/* close connection */
-$mysqli->close();
-?>
]]>
&style.procedural;
]]>
&examples.outputs;