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