mirror of
https://github.com/php/php-src.git
synced 2024-09-25 03:47:26 +00:00
307c1f6bf0
Check if the SQLSTATE error code is equal to PDO_ERR_NONE before we ask the driver. And if no error is reported skip the extra call to the driver.
84 lines
1.7 KiB
PHP
84 lines
1.7 KiB
PHP
--TEST--
|
|
PDO Common: Bug #64172 errorInfo is not properly cleaned up
|
|
--SKIPIF--
|
|
<?php # vim:ft=php
|
|
if (!extension_loaded('pdo')) die('skip');
|
|
$dir = getenv('REDIR_TEST_DIR');
|
|
if (false == $dir) die('skip no driver');
|
|
require_once $dir . 'pdo_test.inc';
|
|
PDOTest::skip();
|
|
?>
|
|
--FILE--
|
|
<?php
|
|
if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.dirname(__FILE__) . '/../../pdo/tests/');
|
|
require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
|
|
|
|
$db = PDOTest::factory();
|
|
|
|
@$db->exec("DROP TABLE test");
|
|
$db->exec("CREATE TABLE test (x int)");
|
|
$db->exec("INSERT INTO test VALUES (1)");
|
|
|
|
echo "===FAIL===\n";
|
|
$db->query('SELECT * FROM bad_table');
|
|
echo "\n";
|
|
echo "===TEST===\n";
|
|
var_dump(is_string($db->errorInfo()[0])) . "\n";
|
|
var_dump(is_int($db->errorInfo()[1])) . "\n";
|
|
var_dump(is_string($db->errorInfo()[2])) . "\n";
|
|
echo "===GOOD===\n";
|
|
$stmt = $db->query('SELECT * FROM test');
|
|
$stmt->fetchAll();
|
|
$stmt = null;
|
|
var_dump($db->errorInfo());
|
|
|
|
echo "===FAIL===\n";
|
|
$db->exec("INSERT INTO bad_table VALUES(1)");
|
|
echo "\n";
|
|
echo "===TEST===\n";
|
|
var_dump(is_string($db->errorInfo()[0])) . "\n";
|
|
var_dump(is_int($db->errorInfo()[1])) . "\n";
|
|
var_dump(is_string($db->errorInfo()[2])) . "\n";
|
|
echo "===GOOD===\n";
|
|
$db->exec("INSERT INTO test VALUES (2)");
|
|
var_dump($db->errorInfo());
|
|
|
|
$db->exec("DROP TABLE test");
|
|
?>
|
|
===DONE===
|
|
--EXPECTF--
|
|
===FAIL===
|
|
|
|
Warning: PDO::query(): SQLSTATE[%s]: %s
|
|
%A
|
|
===TEST===
|
|
bool(true)
|
|
bool(true)
|
|
bool(true)
|
|
===GOOD===
|
|
array(3) {
|
|
[0]=>
|
|
string(5) "00000"
|
|
[1]=>
|
|
NULL
|
|
[2]=>
|
|
NULL
|
|
}
|
|
===FAIL===
|
|
|
|
Warning: PDO::exec(): SQLSTATE[%s]: %s
|
|
%A
|
|
===TEST===
|
|
bool(true)
|
|
bool(true)
|
|
bool(true)
|
|
===GOOD===
|
|
array(3) {
|
|
[0]=>
|
|
string(5) "00000"
|
|
[1]=>
|
|
NULL
|
|
[2]=>
|
|
NULL
|
|
}
|
|
===DONE===
|