2

I'm facing a problem:

Here's the code:

/* connection */
$gaSql['user']       = $dbuname;
$gaSql['password']   = $dbpass;
$gaSql['db']         = $dbname;
$gaSql['server']     = $dbhost;

$gaSql['link'] = pg_connect(
    " host=".$gaSql['server'].
    " dbname=".$gaSql['db'].
    " user=".$gaSql['user'].
    " password=".$gaSql['password']
) or die('Could not connect: ' . pg_last_error());


/* query */
$sQuery = "SELECT * FROM person";

$rResult = pg_query( $gaSql['link'], $sQuery ) or die(pg_last_error());

$iTotal = pg_num_rows($rResult);

while ( $aRow = pg_fetch_array($rResult, null, PGSQL_ASSOC) ) {
    //do something...
}

My problem is:

Assumed table person have total 10 rows. The variable $iTotal returned the correct number of rows: 10. But, when I try to fetch it using pg_fetch_array, it cannot fetch (it didn't enter the while operation).

What's wrong with this situation? Please, can anyone help me?

Thank you so much.

joshua14
  • 135
  • 2
  • 13

0 Answers0