xref: /PHP-8.0/ext/pdo/tests/bug_73234.phpt (revision 30589258)
1--TEST--
2PDO Common: Bug #73234 (Emulated statements let value dictate parameter type)
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$db = PDOTest::factory();
12if ($db->getAttribute(PDO::ATTR_DRIVER_NAME) == 'oci') {
13    die("xfail PDO::PARAM_NULL is not honored by OCI driver, related with bug #81586");
14}
15?>
16--FILE--
17<?php
18if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.__DIR__ . '/../../pdo/tests/');
19require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
20
21$db = PDOTest::factory();
22$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
23$db->exec('CREATE TABLE test(id INT NULL)');
24
25$stmt = $db->prepare('INSERT INTO test VALUES(:value)');
26
27$stmt->bindValue(':value', 0, PDO::PARAM_NULL);
28$stmt->execute();
29
30$stmt->bindValue(':value', null, PDO::PARAM_NULL);
31$stmt->execute();
32
33$stmt = $db->query('SELECT * FROM test');
34var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
35?>
36--EXPECT--
37array(2) {
38  [0]=>
39  array(1) {
40    ["id"]=>
41    NULL
42  }
43  [1]=>
44  array(1) {
45    ["id"]=>
46    NULL
47  }
48}
49