mirror of
https://github.com/php/doc-de.git
synced 2026-03-25 15:52:10 +01:00
git-svn-id: https://svn.php.net/repository/phpdoc/de/trunk@288874 c90b9560-bf6c-de11-be94-00142212c4b1
206 lines
6.1 KiB
XML
206 lines
6.1 KiB
XML
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: af4410a7e15898c3dbe83d6ea38246745ed9c6fb Maintainer: conni Status: ready -->
|
|
<refentry xml:id="function.pg-fetch-array" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>pg_fetch_array</refname>
|
|
<refpurpose>Holt eine Zeile als Array</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>array</type><methodname>pg_fetch_array</methodname>
|
|
<methodparam><type>resource</type><parameter>result</parameter></methodparam>
|
|
<methodparam choice="opt"><type>int</type><parameter>row</parameter></methodparam>
|
|
<methodparam choice="opt"><type>int</type><parameter>result_type</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
<function>pg_fetch_array</function> gibt ein Array zurück, das die
|
|
gelesene Zeile (Tupel, Datensatz) enthält.
|
|
</para>
|
|
<para>
|
|
<function>pg_fetch_array</function> ist eine erweiterte Version
|
|
von <function>pg_fetch_row</function>. Zusätzlich zur
|
|
Speicherung der Daten in einem numerischen Array (mit den
|
|
Feldindizes) speichert diese Funktion die Daten auch in einem
|
|
assoziativen Array, mit den Feldnamen als Indizes. In der
|
|
Standardeinstellung wird ein Array mit beiden Indextypen
|
|
zurückgegeben.
|
|
</para>
|
|
&database.fetch-null;
|
|
<para>
|
|
<function>pg_fetch_array</function> ist NICHT wesentlich
|
|
langsamer als <function>pg_fetch_row</function> oder <function>pg_fetch_assoc</function>,
|
|
ist aber viel einfacher zu benutzen.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>result</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
PostgreSQL Verbindungskennung, die (unter anderem) von den
|
|
Funktionen <function>pg_query</function>,
|
|
<function>pg_query_params</function> oder <function>pg_execute</function> zurückgegeben wurde.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>row</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Die Nummer der Zeile des Abfrageergebnisses, die geholt werden
|
|
soll. Die Nummerierung beginnt bei 0. Fehlt dieser Parameter, so
|
|
wird jeweils die nächste Zeile geholt.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>result_type</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Ein optionaler Parameter, mit dem bestimmt werden kann, wie das
|
|
<type>array</type> indiziert sein soll.
|
|
<parameter>result_type</parameter> ist eine Konstante, die die
|
|
Werte <constant>PGSQL_ASSOC</constant>, <constant>PGSQL_NUM</constant>
|
|
oder <constant>PGSQL_BOTH</constant> annehmen kann.
|
|
Mit der Konstanten <constant>PGSQL_NUM</constant> gibt <function>pg_fetch_array</function>
|
|
ein numerisch indiziertes Array zurück, mit der Konstanten
|
|
<constant>PGSQL_ASSOC</constant> ein assoziatives Array. Die
|
|
Standardeinstellung ist <constant>PGSQL_BOTH</constant>, mit der
|
|
ein Array sowohl mit numerischen als auch assoziativen Indizes
|
|
zurückgegeben wird.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
Ein <type>array</type>, das entweder numerisch (bei 0 beginnend)
|
|
oder assoziativ indiziert ist, oder beides. Jeder Wert im
|
|
<type>array</type> wird als <type>string</type> repräsentiert.
|
|
Nullwerte der Datenbank (<literal>NULL</literal>) werden als &null;
|
|
zurückgegeben.
|
|
</para>
|
|
<para>
|
|
Bei einem Fehler oder wenn der Parameter <parameter>row</parameter>
|
|
größer als die Anzahl der Zeilen im Abfrageergebnis ist, oder wenn
|
|
kein Datensatz mehr gelesen werden kann, wird &false; zurückgegeben.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="changelog">
|
|
&reftitle.changelog;
|
|
<para>
|
|
<informaltable>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>&Version;</entry>
|
|
<entry>&Description;</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>4.1.0</entry>
|
|
<entry>
|
|
Der Parameter <parameter>row</parameter> wurde optional.
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>4.0.0</entry>
|
|
<entry>
|
|
Der Parameter <parameter>result_type</parameter> wurde hinzugefügt.
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title><function>pg_fetch_array</function> Beispiel</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
|
|
$conn = pg_pconnect("dbname=publisher");
|
|
if (!$conn) {
|
|
echo "Konnte keine Verbindung aufbauen.\n";
|
|
exit;
|
|
}
|
|
|
|
$result = pg_query($conn, "SELECT author, email FROM authors");
|
|
if (!$result) {
|
|
echo "Ein Fehler ist aufgetreten.\n";
|
|
exit;
|
|
}
|
|
|
|
$arr = pg_fetch_array($result, 0, PGSQL_NUM);
|
|
echo $arr[0] . " <- Zeile 1 Autor\n";
|
|
echo $arr[1] . " <- Zeile 1 E-mail\n";
|
|
|
|
// Seit PHP 4.1.0 ist der Parameter row optional. Stattdessen kann
|
|
// NULL übergeben werden. Aufeinanderfolgende Aufrufe von
|
|
// pg_fetch_array liefern jeweils den nächsten Datensatz.
|
|
$arr = pg_fetch_array($result, NULL, PGSQL_ASSOC);
|
|
echo $arr["author"] . " <- Zeile 2 Autor\n";
|
|
echo $arr["email"] . " <- Zeile 2 E-mail\n";
|
|
|
|
$arr = pg_fetch_array($result);
|
|
echo $arr["author"] . " <- Zeile 3 Autor\n";
|
|
echo $arr[1] . " <- Zeile 3 E-mail\n";
|
|
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>pg_fetch_row</function></member>
|
|
<member><function>pg_fetch_object</function></member>
|
|
<member><function>pg_fetch_result</function></member>
|
|
</simplelist>
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|