xref: /PHP-8.0/ext/pgsql/tests/bug72028.phpt (revision f8d79582)
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--EXPECT--
39array(2) {
40  ["value"]=>
41  NULL
42  ["details"]=>
43  string(38) "insert before looping with a reference"
44}
45array(2) {
46  ["value"]=>
47  NULL
48  ["details"]=>
49  string(37) "insert after looping with a reference"
50}
51