how to get insert_id using mysqli prepare statements
Asked Answered
R

2

8

How can I get the insert_id of the last record using mysqli prepare statement, for example following?

$stmt = $this->mysqli->prepare("INSERT INTO test (name) values (?)")
$stmt->bind_param('s', $name);
$stmt->execute();
Redhanded answered 6/4, 2011 at 23:14 Comment(0)
L
11

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

Leicestershire answered 6/4, 2011 at 23:17 Comment(0)
O
2

mysqli->insert_id

Othilia answered 6/4, 2011 at 23:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.