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

PHP Home Page

Manual Table of Contents
Up to PostgreSQL
Quick Reference
English version of this pageJapanese version of this pageItalian 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
Sat, 12 Aug 2000
pg_Fetch_Object 
Next page


pg_Fetch_Array

(unknown)

pg_Fetch_Array -- Holt eine Datenbankreihe als Array

Beschreibung

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

Rückgabewert: Ein Array, das mit der eingelesenen Reihe identisch ist, oder false, wenn keine Reihe mehr gelesen werden kann.

pg_fetch_array() ist eine erweiterte Version von pg_fetch_row(). Zusätzlich zur Speicherung der Daten in einem aufgezählten Array speichert diese Funktion die Daten in assoziativen Indexen, indem es den Feldnamen als Schlüssel verwendet.

Das dritte optionale Argument result_type in pg_fetch_array() ist eine Konstante, die folgende Werte annehmen kann: PGSQL_ASSOC, PGSQL_NUM und PGSQL_BOTH.

Anmerkung: Result_type wurde in PHP 4.0 hinzugefügt.

Wichtig zu bemerken ist, daß pg_fetch_array() nicht wesentlich langsamer als pg_fetch_row() ist, obwohl eine umfassendere Funktion zur Verfügung gestellt wird.

Für weitere Einzelheiten siehe auch pg_fetch_row()

Beispiel 1. PostgreSQL fetch array


<?php 
$conn = pg_pconnect("","","","","verlag");
if (!$conn) {
    echo "Es ist ein Fehler aufgetreten.\n";
    exit;
}

$result = pg_Exec ($conn, "SELECT * FROM autoren");
if (!$result) {
    echo "Es ist ein Fehler aufgetreten.\n";
    exit;
}

$arr = pg_fetch_array ($result, 0);
echo $arr[0] . " <- array\n";
$arr = pg_fetch_array ($result, 1);
echo $arr["autor"] . " <- 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
Sat, 12 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.