1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
--TEST--
Bug #79132: PDO re-uses parameter values from earlier calls to execute()
--EXTENSIONS--
pdo_mysql
--SKIPIF--
<?php
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
MySQLPDOTest::skip();
?>
--FILE--
<?php
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
$pdo = MySQLPDOTest::factory();
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
test($pdo);
echo "\n";
$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
test($pdo);
function test($pdo) {
$stmt = $pdo->prepare('SELECT ? a, ? b');
$set = [
['a', 'b'],
['x'], /* second parameter is missing */
[1 => 'y'], /* first parameter is missing */
];
foreach ($set as $params) {
try {
var_dump($stmt->execute($params), $stmt->fetchAll(PDO::FETCH_ASSOC));
} catch (PDOException $error) {
echo $error->getMessage() . "\n";
}
}
}
?>
--EXPECT--
bool(true)
array(1) {
[0]=>
array(2) {
["a"]=>
string(1) "a"
["b"]=>
string(1) "b"
}
}
SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens
SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens
bool(true)
array(1) {
[0]=>
array(2) {
["a"]=>
string(1) "a"
["b"]=>
string(1) "b"
}
}
SQLSTATE[HY093]: Invalid parameter number
SQLSTATE[HY093]: Invalid parameter number
|