summaryrefslogtreecommitdiff
path: root/ext/pgsql/tests/80_bug27597.phpt
blob: 7d5b5db89002eb1cfe54967170aaf03767e4c9e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
--TEST--
Bug #27597 (pg_fetch_array not returning false)
--SKIPIF--
<?php 
require_once('skipif.inc');
?>
--FILE--
<?php

require_once(dirname(__FILE__) . '/config.inc');
	
$dbh = @pg_connect($conn_str);
if (!$dbh) {
	die ("Could not connect to the server");
}

@pg_query("DROP TABLE id");
pg_query("CREATE TABLE id (id INT)");

for ($i=0; $i<4; $i++) {
	pg_query("INSERT INTO id (id) VALUES ($i)");
}

function xi_fetch_array($res, $type = PGSQL_ASSOC) {
	$a = pg_fetch_array($res, NULL, $type) ;
	return $a ;	
}

$res = pg_query("SELECT * FROM id");
$i = 0; // endless-loop protection
while($row = xi_fetch_array($res)) {
	print_r($row);
	if ($i++ > 4) {
		echo "ENDLESS-LOOP";
		exit(1);
	}
}

pg_close($dbh);

?>
===DONE===
--EXPECTF--
Array
(
    [id] => 0
)
Array
(
    [id] => 1
)
Array
(
    [id] => 2
)
Array
(
    [id] => 3
)
===DONE===