|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2018-01-13 21:03 UTC] support at vid2chat dot com
Description:
------------
Using mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT) converts all MySQLi errors to exceptions, except for if there is a mismatch in bind_result(). This occurs in both the bound variables and types. An error with the following message is shown:
Warning: mysqli_stmt::bind_param(): Number of variables doesn't match number of parameters in prepared statement
Test script:
---------------
$stmt = $mysqli->prepare("SELECT id, name, age FROM myTable WHERE name = ?");
$stmt->bind_param("si", $_POST['name'], $_POST['age']);
$stmt->execute();
$arr = $stmt->get_result()->fetch_all(MYSQLI_ASSOC);
if(!$arr) exit('No rows');
var_export($arr);
$stmt->close();
Expected result:
----------------
I should be able to catch all MySQLi exceptions, but this specific error is not converted to an exception.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 11:00:02 2025 UTC |
Description: ------------ Using mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT) converts all MySQLi errors to exceptions, except for if there is a mismatch in bind_result(). This occurs in both the bound variables and types. An error with the following message is shown: Warning: mysqli_stmt::bind_param(): Number of variables doesn't match number of parameters in prepared statement Test script: --------------- mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); $stmt = $mysqli->prepare("SELECT * FROM table WHERE name = ?"); $stmt->bind_param("si", $_POST['name'], $_POST['age']); $stmt->execute(); $arr = $stmt->get_result()->fetch_all(MYSQLI_ASSOC); if(!$arr) exit('No rows'); var_export($arr); $stmt->close(); Expected result: ---------------- I should be able to catch all MySQLi exceptions, but this specific error is not converted to an exception.