xref: /PHP-8.0/ext/pgsql/tests/80_bug27597.phpt (revision f8d79582)
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--EXPECT--
43Array
44(
45    [id] => 0
46)
47Array
48(
49    [id] => 1
50)
51Array
52(
53    [id] => 2
54)
55Array
56(
57    [id] => 3
58)
59