xref: /PHP-7.1/ext/pgsql/tests/bug72028.phpt (revision fd6f7b83)
1--TEST--
2Bug #72028 pg_query_params(): NULL converts to empty string
3--SKIPIF--
4<?php include("skipif.inc"); ?>
5--FILE--
6<?php
7// create test table
8
9include('config.inc');
10
11$conn = pg_connect($conn_str);
12
13$table = "bug72028_" . md5(uniqid(time()));
14
15pg_query("CREATE TABLE $table (value TEXT, details TEXT);");
16
17$sql = "INSERT INTO $table (value, details) VALUES ($1, $2)";
18
19$params = array(null, "insert before looping with a reference");
20$result = pg_query_params($conn, $sql, $params);
21
22$params2 = array(null, "insert after looping with a reference");
23foreach ($params2 as &$p) {
24    // doing nothing
25}
26unset($p);
27
28$result = pg_query_params($conn, $sql, $params2);
29
30$r = pg_query("SELECT * FROM $table");
31while (false !== ($i = pg_fetch_assoc($r))) {
32	var_dump($i);
33}
34
35pg_query("DROP TABLE $table");
36
37?>
38==DONE==
39--EXPECT--
40array(2) {
41  ["value"]=>
42  NULL
43  ["details"]=>
44  string(38) "insert before looping with a reference"
45}
46array(2) {
47  ["value"]=>
48  NULL
49  ["details"]=>
50  string(37) "insert after looping with a reference"
51}
52==DONE==
53