1--TEST-- 2PDO Common: Bug #64172 errorInfo is not properly cleaned up 3--SKIPIF-- 4<?php 5if (!extension_loaded('pdo')) die('skip'); 6$dir = getenv('REDIR_TEST_DIR'); 7if (false == $dir) die('skip no driver'); 8require_once $dir . 'pdo_test.inc'; 9PDOTest::skip(); 10?> 11--FILE-- 12<?php 13if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.__DIR__ . '/../../pdo/tests/'); 14require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc'; 15 16$db = PDOTest::factory(); 17 18@$db->exec("DROP TABLE test"); 19$db->exec("CREATE TABLE test (x int)"); 20$db->exec("INSERT INTO test VALUES (1)"); 21 22echo "===FAIL===\n"; 23$db->query('SELECT * FROM bad_table'); 24echo "\n"; 25echo "===TEST===\n"; 26var_dump(is_string($db->errorInfo()[0])) . "\n"; 27var_dump(is_int($db->errorInfo()[1])) . "\n"; 28var_dump(is_string($db->errorInfo()[2])) . "\n"; 29echo "===GOOD===\n"; 30$stmt = $db->query('SELECT * FROM test'); 31$stmt->fetchAll(); 32$stmt = null; 33var_dump($db->errorInfo()); 34 35echo "===FAIL===\n"; 36$db->exec("INSERT INTO bad_table VALUES(1)"); 37echo "\n"; 38echo "===TEST===\n"; 39var_dump(is_string($db->errorInfo()[0])) . "\n"; 40var_dump(is_int($db->errorInfo()[1])) . "\n"; 41var_dump(is_string($db->errorInfo()[2])) . "\n"; 42echo "===GOOD===\n"; 43$db->exec("INSERT INTO test VALUES (2)"); 44var_dump($db->errorInfo()); 45 46$db->exec("DROP TABLE test"); 47?> 48--EXPECTF-- 49===FAIL=== 50 51Warning: PDO::query(): SQLSTATE[%s]: %s 52%A 53===TEST=== 54bool(true) 55bool(true) 56bool(true) 57===GOOD=== 58array(3) { 59 [0]=> 60 string(5) "00000" 61 [1]=> 62 NULL 63 [2]=> 64 NULL 65} 66===FAIL=== 67 68Warning: PDO::exec(): SQLSTATE[%s]: %s 69%A 70===TEST=== 71bool(true) 72bool(true) 73bool(true) 74===GOOD=== 75array(3) { 76 [0]=> 77 string(5) "00000" 78 [1]=> 79 NULL 80 [2]=> 81 NULL 82} 83