如何使用mysqli准备语句获取insert_id

8

如何使用mysqli prepare语句获取最后一条记录的insert_id,例如以下示例?

$stmt = $this->mysqli->prepare("INSERT INTO test (name) values (?)")
$stmt->bind_param('s', $name);
$stmt->execute();
2个回答

11

$stmt->execute()之后,$new_id = $this->mysqli->insert_id;


2

{{link1:mysqli->insert_id}}

(Note: This is the same text in Chinese, just with the appropriate characters for punctuation and symbols.)

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接