xref: /PHP-7.4/ext/pgsql/tests/80_bug27597.phpt (revision 26dfce7f)
1--TEST--
2Bug #27597 (pg_fetch_array not returning false)
3--SKIPIF--
4<?php
5require_once('skipif.inc');
6?>
7--FILE--
8<?php
9
10require_once(__DIR__ . '/config.inc');
11
12$dbh = @pg_connect($conn_str);
13if (!$dbh) {
14	die ("Could not connect to the server");
15}
16
17@pg_query("DROP TABLE id");
18pg_query("CREATE TABLE id (id INT)");
19
20for ($i=0; $i<4; $i++) {
21	pg_query("INSERT INTO id (id) VALUES ($i)");
22}
23
24function xi_fetch_array($res, $type = PGSQL_ASSOC) {
25	$a = pg_fetch_array($res, NULL, $type) ;
26	return $a ;
27}
28
29$res = pg_query("SELECT * FROM id");
30$i = 0; // endless-loop protection
31while($row = xi_fetch_array($res)) {
32	print_r($row);
33	if ($i++ > 4) {
34		echo "ENDLESS-LOOP";
35		exit(1);
36	}
37}
38
39pg_close($dbh);
40
41?>
42===DONE===
43--EXPECT--
44Array
45(
46    [id] => 0
47)
48Array
49(
50    [id] => 1
51)
52Array
53(
54    [id] => 2
55)
56Array
57(
58    [id] => 3
59)
60===DONE===
61