Which is correct way to get last inserted id in mysqli prepared statements procedural style?
- 阅读更多 关于 Which is correct way to get last inserted id in mysqli prepared statements procedural style?
i am using mysqli prepared statement to insert record in the table like this $link = mysqli_connect('localhost', 'my_user', 'my_password', 'world'); /* check connection */ if (!$link) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } $stmt = mysqli_prepare($link, "INSERT INTO CountryLanguage VALUES (?, ?, ?, ?)"); mysqli_stmt_bind_param($stmt, 'sssd', $code, $language, $official, $percent); $code = 'DEU'; $language = 'Bavarian'; $official = "F"; $percent = 11.2; /* execute prepared statement */ mysqli_stmt_execute($stmt); if(mysqli_stmt_affected_rows($stmt) > 0){ //if insert