문제

I am attempting to retrieve the latest id from the DB and it works in my terminal but will not work as a prepared statement.

Here is my code.It all works up to it, inserting and pulling a id if it is not through the max function.

$stmt=$mysqli->prepare("select id from pickup where id in (select max(id) from pickup)");
$stmt->bind_result($id);
$stmt->fetch();
$stmt->close();
$mysqli->close();
return $id;
도움이 되었습니까?

해결책

check

$stmt=$mysqli->prepare("select max(id) as id from pickup");
$stmt->execute();
$stmt->bind_result($id);
$stmt->fetch();
$ret_id = $id;
$stmt->close();
$mysqli->close();
return $ret_id;
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top