xref: /php-src/ext/pdo/tests/gh8626.phpt (revision 218a93b8)
1--TEST--
2GH-8626: PDOStatement->execute() failed, then execute successfully, errorInfo() information is incorrect
3--EXTENSIONS--
4pdo
5--SKIPIF--
6<?php
7$dir = getenv('REDIR_TEST_DIR');
8if (false == $dir) die('skip no driver');
9require_once $dir . 'pdo_test.inc';
10PDOTest::skip();
11
12$db = PDOTest::factory();
13if ($db->getAttribute(PDO::ATTR_DRIVER_NAME) == 'oci') {
14    die("xfail OCI driver errorInfo is inconsistent with other PDO drivers");
15}
16?>
17--FILE--
18<?php
19if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.__DIR__ . '/../../pdo/tests/');
20require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
21
22$db = PDOTest::factory();
23$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT);
24
25$db->exec('CREATE TABLE test8626 (x int NOT NULL)');
26
27$stmt = $db->prepare('INSERT INTO test8626 VALUES(?)');
28
29// fail
30var_dump($stmt->execute([null]), $stmt->errorCode());
31$errorInfo = $stmt->errorInfo();
32var_dump(array_slice($errorInfo, 0, 3)); // odbc, dblib
33
34$stmt->closeCursor(); // sqlite
35
36// success
37var_dump($stmt->execute([1]), $stmt->errorCode());
38$errorInfo = $stmt->errorInfo();
39var_dump(array_slice($errorInfo, 0, 3)); // odbc, dblib
40?>
41===DONE===
42--CLEAN--
43<?php
44require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
45$db = PDOTest::factory();
46PDOTest::dropTableIfExists($db, "test8626");
47?>
48--EXPECTF--
49bool(false)
50string(%d) "%s"
51array(3) {
52  [0]=>
53  string(%d) "%s"
54  [1]=>
55  int(%i)
56  [2]=>
57  string(%d) "%s%w%S"
58}
59bool(true)
60string(5) "00000"
61array(3) {
62  [0]=>
63  string(5) "00000"
64  [1]=>
65  NULL
66  [2]=>
67  NULL
68}
69===DONE===
70