在使用 mysqli 准备时,我如何查看 MYSQL 执行的状态


How do i see that status of MYSQL execution when using mysqli prepare?

>我有这个:

$mysqli = new mysqli( '127.0.0.1', 'root', 'P', '_db' );

{
$xkey=$key2+1;
$stmt = $mysqli->prepare("UPDATE blablabla mysql
$stmt->bind_param('ii', $xkey, $strings);
$stmt->execute();
}
}

我需要根据它是否失败来回应不同的事情。我试过这个

if(!$stmt){
then
//do
}else{
//do
}

但它没有用。

http://php.net/manual/en/mysqli-stmt.execute.php

成功时返回 TRUE,失败时返回 FALSE。

$status = $stmt->execute();
if ($status === true) {
    // good
}
else {
    // bad
}