|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2020-01-16 18:00 UTC] cmb@php.net
-Assigned To:
+Assigned To: cmb
[2020-01-17 12:25 UTC] cmb@php.net
-Status: Assigned
+Status: Verified
-Assigned To: cmb
+Assigned To:
[2020-01-17 12:25 UTC] cmb@php.net
[2020-01-17 12:41 UTC] cmb@php.net
[2020-12-11 15:36 UTC] nikic@php.net
[2020-12-11 15:36 UTC] nikic@php.net
-Status: Verified
+Status: Closed
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 17:00:02 2025 UTC |
Description: ------------ When executing the same statement, missing parameter values are filled in with values from earlier executions instead of throwing an error. This requires emulated PREPARE to be disabled. Test script: --------------- $host = ''; $db = ''; $user = ''; $pass = ''; $options = [ PDO::ATTR_EMULATE_PREPARES => false, /* required */ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, ]; $pdo = new PDO("mysql:host=$host; dbname=$db; charset=utf8mb4", $user, $pass, $options); $stmt = $pdo->prepare('select ? a, ? b'); $set = [ ['a', 'b'], [1 => 'y'], /* first parameter is missing. Note the array key */ ['x'], /* second parameter is missing */ ]; foreach ($set as $params) { try { var_dump($stmt->execute($params), $stmt->fetchAll(PDO::FETCH_ASSOC)); } catch (Throwable $error) { echo $error->getMessage() . "\n"; } } Expected result: ---------------- When emulated PREPARE is enabled, an error "SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens" is thrown. The same error should be thrown instead of values being re-used. Actual result: -------------- bool(true) array(1) { [0]=> array(2) { ["a"]=> string(1) "a" ["b"]=> string(1) "b" } } bool(true) array(1) { [0]=> array(2) { ["a"]=> string(1) "a" ["b"]=> string(1) "y" } } bool(true) array(1) { [0]=> array(2) { ["a"]=> string(1) "x" ["b"]=> string(1) "y" } }