xref: /PHP-7.3/ext/pdo/tests/bug_73234.phpt (revision 32b6154a)
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--FILE--
12<?php
13if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.dirname(__FILE__) . '/../../pdo/tests/');
14require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
15
16$db = PDOTest::factory();
17$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
18$db->exec('CREATE TABLE test(id INT NULL)');
19
20$stmt = $db->prepare('INSERT INTO test VALUES(:value)');
21
22$stmt->bindValue(':value', 0, PDO::PARAM_NULL);
23$stmt->execute();
24
25$stmt->bindValue(':value', null, PDO::PARAM_NULL);
26$stmt->execute();
27
28$stmt = $db->query('SELECT * FROM test');
29var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
30?>
31--EXPECT--
32array(2) {
33  [0]=>
34  array(1) {
35    ["id"]=>
36    NULL
37  }
38  [1]=>
39  array(1) {
40    ["id"]=>
41    NULL
42  }
43}
44