MySQLi_STMT
在线手册:中文  英文

mysqli_stmt::$insert_id

mysqli_stmt_insert_id

(PHP 5)

mysqli_stmt::$insert_id -- mysqli_stmt_insert_idGet the ID generated from the previous INSERT operation

说明

面向对象风格

过程化风格

mixed mysqli_stmt_insert_id ( mysqli_stmt $stmt )
Warning

本函数还未编写文档,仅有参数列表。


MySQLi_STMT
在线手册:中文  英文

用户评论:

hgernhardt at tcnewengland dot org (2011-02-07 07:33:40)

It should be noted that using mysqli_stmt->insert_id will not result in a unique ID being returned for each execution of a prepared insert statement. In practice, it appears that the first insertion ID is returned. If you are performing multiple inserts with the same prepared statement (one invocation of mysqli_stmt::prepare and multiple invocations of mysqli_stmt::execute() for a given statement), and need to keep the unique ID for each insert, use mysqli_connection->insert_id.

php at paulbutler dot org (2007-07-31 15:50:19)

This can be used as a property of a statement as well:

<?php

$statement 
$mysqli->prepare($query);

echo 
$statement->insert_id;

?>

易百教程