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