-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes GH-8626: Fix PDOStatement->execute() failed.
Then execute successfully, errorInfo() information is incorrect
- Loading branch information
Showing
4 changed files
with
72 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
--TEST-- | ||
GH-8626: PDOStatement->execute() failed, then execute successfully, errorInfo() information is incorrect | ||
--SKIPIF-- | ||
<?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='.__DIR__ . '/../../pdo/tests/'); | ||
require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc'; | ||
|
||
$db = PDOTest::factory(); | ||
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT); | ||
|
||
$db->exec('DROP TABLE test'); | ||
$db->exec('CREATE TABLE test (x int NOT NULL)'); | ||
|
||
$stmt = $db->prepare('INSERT INTO test VALUES(?)'); | ||
|
||
// fail | ||
var_dump($stmt->execute([null]), $stmt->errorCode()); | ||
$errorInfo = $stmt->errorInfo(); | ||
if (isset($errorInfo[3])) { | ||
unset($errorInfo[3]); // odbc | ||
} | ||
var_dump($errorInfo); | ||
|
||
$stmt->closeCursor(); // sqlite | ||
|
||
// success | ||
var_dump($stmt->execute([1]), $stmt->errorCode()); | ||
$errorInfo = $stmt->errorInfo(); | ||
if (isset($errorInfo[3])) { | ||
unset($errorInfo[3]); // odbc | ||
} | ||
var_dump($errorInfo); | ||
?> | ||
===DONE=== | ||
--EXPECTF-- | ||
bool(false) | ||
string(%d) "%s" | ||
array(3) { | ||
[0]=> | ||
string(%d) "%s" | ||
[1]=> | ||
int(%d) | ||
[2]=> | ||
string(%d) "%s%w%S" | ||
} | ||
bool(true) | ||
string(5) "00000" | ||
array(3) { | ||
[0]=> | ||
string(5) "00000" | ||
[1]=> | ||
NULL | ||
[2]=> | ||
NULL | ||
} | ||
===DONE=== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters