我正在使用 PHP 和 mysqli 準(zhǔn)備好的語(yǔ)句。是否有令人信服的理由在執(zhí)行時(shí)手動(dòng)檢查錯(cuò)誤mysqli_stmt_prepare()?更具體地說(shuō),我不只是詢問(wèn)準(zhǔn)備語(yǔ)句行的最終結(jié)果。$sql = "SELECT * FROM `users`;";$stmt = mysqli_stmt_init($db);mysqli_stmt_prepare($stmt, $sql); // How should I check for error in heremysqli_stmt_execute($stmt);$result = mysqli_stmt_get_result($stmt);PHP 手冊(cè)將這一行且僅將這一行放在一條if語(yǔ)句中。$sql = "SELECT * FROM `users`;";$stmt = mysqli_stmt_init($db);if (mysqli_stmt_prepare($stmt, 'SELECT * FROM `users`;')) { mysqli_stmt_execute($stmt); $result = mysqli_stmt_get_result($stmt);}我想知道在 mysqli 中使用準(zhǔn)備好的語(yǔ)句時(shí)如何正確檢查錯(cuò)誤。是否有充分的理由手動(dòng)檢查手冊(cè)中顯示的該函數(shù)的返回值?
我應(yīng)該在調(diào)用“mysqli_stmt_prepare”時(shí)手動(dòng)檢查錯(cuò)誤嗎?
三國(guó)紛爭(zhēng)
2023-04-28 17:27:07