xref: /PHP-8.3/ext/pdo/tests/pdo_039.phpt (revision 2db2cab6)
1--TEST--
2PDO Common: errorCode()
3--EXTENSIONS--
4pdo
5--SKIPIF--
6<?php
7$dir = getenv('REDIR_TEST_DIR');
8if (false == $dir) die('skip no driver');
9if (str_starts_with(getenv('PDOTEST_DSN'), "firebird")) die('xfail firebird driver does not behave as expected');
10require_once $dir . 'pdo_test.inc';
11PDOTest::skip();
12?>
13--FILE--
14<?php
15if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.__DIR__ . '/../../pdo/tests/');
16
17$dsn = getenv('PDOTEST_DSN');
18$user = getenv('PDOTEST_USER');
19$pass = getenv('PDOTEST_PASS');
20$attr = getenv('PDOTEST_ATTR');
21if (is_string($attr) && strlen($attr)) {
22    $attr = unserialize($attr);
23} else {
24    $attr = null;
25}
26
27if ($user === false) $user = NULL;
28if ($pass === false) $pass = NULL;
29
30$conn = new PDO($dsn, $user, $pass, $attr);
31
32var_dump($conn->errorCode());
33
34$query = 'SELECT 1';
35if ($conn->getAttribute(PDO::ATTR_DRIVER_NAME) === 'oci') {
36    $query .= ' FROM DUAL';
37}
38var_dump($conn->errorCode());
39var_dump($conn->errorCode());
40
41$stmt = $conn->prepare($query);
42var_dump($conn->errorCode());
43var_dump($stmt->errorCode());
44
45$stmt->execute();
46var_dump($stmt->errorCode());
47var_dump($stmt->errorCode());
48
49?>
50--EXPECT--
51NULL
52string(5) "00000"
53string(5) "00000"
54string(5) "00000"
55NULL
56string(5) "00000"
57string(5) "00000"
58