Skip to content

Commit fd6f7b8

Browse files
committed
Add test for bug #72028
1 parent d859094 commit fd6f7b8

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

ext/pgsql/tests/bug72028.phpt

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
--TEST--
2+
Bug #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+
9+
include('config.inc');
10+
11+
$conn = pg_connect($conn_str);
12+
13+
$table = "bug72028_" . md5(uniqid(time()));
14+
15+
pg_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");
23+
foreach ($params2 as &$p) {
24+
// doing nothing
25+
}
26+
unset($p);
27+
28+
$result = pg_query_params($conn, $sql, $params2);
29+
30+
$r = pg_query("SELECT * FROM $table");
31+
while (false !== ($i = pg_fetch_assoc($r))) {
32+
var_dump($i);
33+
}
34+
35+
pg_query("DROP TABLE $table");
36+
37+
?>
38+
==DONE==
39+
--EXPECT--
40+
array(2) {
41+
["value"]=>
42+
NULL
43+
["details"]=>
44+
string(38) "insert before looping with a reference"
45+
}
46+
array(2) {
47+
["value"]=>
48+
NULL
49+
["details"]=>
50+
string(37) "insert after looping with a reference"
51+
}
52+
==DONE==

0 commit comments

Comments
 (0)