8

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

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

2 回答 2

11

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

于 2011-04-06T23:17:06.340 回答
2

mysqli->insert_id

于 2011-04-06T23:16:35.113 回答