★ wanayoo — archive 1999 http://www.php.net/manual/it/function.pg-fetch-array.phpNouvelle recherche | Portail wanayoo

PHP Home Page

Manual Table of Contents
Up to PostgreSQL
Quick Reference
English version of this pageGerman version of this pageJapanese version of this pageFrench version of this pageHungarian version of this page
PostgreSQL
* pg_Close
* pg_cmdTuples
* pg_Connect
* pg_DBname
* pg_ErrorMessage
* pg_Exec
* pg_Fetch_Array
* pg_Fetch_Object
* pg_Fetch_Row
* pg_FieldIsNull
* pg_FieldName
* pg_FieldNum
* pg_FieldPrtLen
* pg_FieldSize
* pg_FieldType
* pg_FreeResult
* pg_GetLastOid
* pg_Host
* pg_loclose
* pg_locreate
* pg_loexport
* pg_loimport
* pg_loopen
* pg_loread
* pg_loreadall
* pg_lounlink
* pg_lowrite
* pg_NumFields
* pg_NumRows
* pg_Options
* pg_pConnect
* pg_Port
* pg_Result
* pg_trace
* pg_tty
* pg_untrace
Manual: pg_Fetch_Array
View the source code for this pageSearch the site



Previous page
 pg_Exec
 Updated
Sun, 06 Aug 2000
pg_Fetch_Object 
Next page


pg_Fetch_Array

(unknown)

pg_Fetch_Array -- elabora una riga come un vettore

Descrizione

array pg_fetch_array (int result, int row [, int result_type])

Restituisce: Un vettore che corrisponde alla riga elaborata, o falso se non ci sono ulteriori righe.

pg_fetch_array() è una versione estesa di pg_fetch_row(). Oltre a salvare i dati negli indici numerici del vettore del result, essa salva anche i dati in indici associativi, usando i nomi dei campi come chiavi.

Il terzo parametro opzionale result_type in pg_fetch_array() è una costante e può assumere i seguenti valori: PGSQL_ASSOC, PGSQL_NUM, e PGSQL_BOTH.

Nota: Result_type è stato aggiunto in PHP 4.0.

Un'importante cosa da notare è che l'utilizzo di pg_fetch_array() NON è in modo significativo più lento che usare pg_fetch_row(), anche se fornisce un significativo valore aggiunto.

Per ulteriori dettagli, vedere anche pg_fetch_row()

Esempio 1. elaborazione in un vettore di PostgreSQL


<?php 
$conn = pg_pconnect("","","","","publisher");
if (!$conn) {
    echo "An error occured.\n";
    exit;
}

$result = pg_Exec ($conn, "SELECT * FROM authors");
if (!$result) {
    echo "An error occured.\n";
    exit;
}

$arr = pg_fetch_array ($result, 0);
echo $arr[0] . " <- array\n";

$arr = pg_fetch_array ($result, 1);
echo $arr["author"] . " <- array\n";
?>
     

User Contributed Notes: pg_Fetch_Array


henrry@rocketmail.com
31-Jul-2000 05:03
I have a little problem with your pg_fetch_array. Sometimes get this message : "Warning: Unable to jump to row 3 on PostgresSQL result index 2 in database.php on line 65". And sometimes the warning didn't appear. I just could fix it. My source program is :
function Select_db ($db_nama,$syn_SQL,$n_field)
{
$hasil_qry=pg_exec($db_nama,$syn_SQL);
$row=0;
while($data=pg_fetch_array($hasil_qry,$row)):
for($i=0;$i<$n_field;$i++)
echo $data[$i]." ";
echo "
";
$row++;
endwhile;
}
Could anyone tell me what the problem ?



ecestari@hotmail.Com
04-Aug-2000 09:25
It is because $row is incremented one time too many. Try instead :

$result=pg_exec($handle,$query);

$row=0;

$max_row=pg_numrows($result);

while($row < $max_row) {

$data=pg_fetch_object($result,$row);

///Some more code

}

And you'll get rid of those error messages
c*



 About Notes


Previous page
 pg_Exec
 Updated
Sun, 06 Aug 2000
pg_Fetch_Object 
Next page





Who's responsible for this?
Top of this page

Site
Hosting:



Located in
United States
Elements of this website are subject to copyright.
Questions about installing or using PHP should be directed to one of the mailing lists.
Only questions about the website should be directed to webmaster@php.net.