mirror of
https://github.com/macintoshplus/doc-fr.git
synced 2026-03-30 04:42:24 +02:00
git-svn-id: https://svn.php.net/repository/phpdoc/fr/trunk@164386 c90b9560-bf6c-de11-be94-00142212c4b1
124 lines
3.9 KiB
XML
124 lines
3.9 KiB
XML
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!-- $Revision: 1.9 $ -->
|
|
<!-- EN-Revision: 1.9 Maintainer: yannick Status: ready -->
|
|
<refentry id="function.pg-fetch-array">
|
|
<refnamediv>
|
|
<refname>pg_fetch_array</refname>
|
|
<refpurpose>Lit une ligne de résultat PostgreSQL dans un tableau</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<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> retourne un tableau qui contient
|
|
la ligne demandée, dans le résultat identifiée
|
|
par <parameter>result</parameter>, et &false; , s'il ne
|
|
reste plus de lignes.
|
|
</para>
|
|
&database.fetch-null;
|
|
<para>
|
|
<parameter>row</parameter> est le numéro de la ligne (enregistrement).
|
|
La première ligne a pour numéro 0.
|
|
</para>
|
|
<para>
|
|
<function>pg_fetch_array</function> est une version évoluée de
|
|
<function>pg_fetch_row</function>. En plus de proposer un tableau à
|
|
indice numérique, elle peut aussi enregistrer les données
|
|
dans un tableau associatif, en utilisant les noms des champs comme
|
|
clés.
|
|
</para>
|
|
<para>
|
|
L'argument optionnel <parameter>result_type</parameter> de
|
|
<function>pg_fetch_array</function> est une constante, qui peut prendre les
|
|
valeurs suivantes : <constant>PGSQL_ASSOC</constant>,
|
|
<constant>PGSQL_NUM</constant> et <constant>PGSQL_BOTH</constant>.
|
|
<function>pg_fetch_array</function> retourne un tableau
|
|
associatif dont les clés sont les noms de colonnes, avec la
|
|
constante <constant>PGSQL_ASSOC</constant>; les index
|
|
de colonnes avec <constant>PGSQL_NUM</constant>, et
|
|
les deux avec la constante <constant>PGSQL_BOTH</constant>
|
|
La valeur par défaut est <constant>PGSQL_BOTH</constant>.
|
|
<note>
|
|
<para>
|
|
<parameter>result_type</parameter> a été ajoutée en
|
|
&php; 4.0.
|
|
</para>
|
|
</note>
|
|
</para>
|
|
<para>
|
|
Il est important de noter que <function>pg_fetch_array</function> n'est pas
|
|
significativement plus lent que <function>pg_fetch_row</function>, tandis
|
|
qu'elle fournit un confort d'utilisation notable.
|
|
</para>
|
|
<para>
|
|
<example>
|
|
<title>Exemple avec <function>pg_fetch_array</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
|
|
$conn = pg_pconnect ("dbname=publisher");
|
|
if (!$conn) {
|
|
echo "Erreur de connexion.\n";
|
|
exit;
|
|
}
|
|
|
|
$result = pg_query ($conn, "SELECT * FROM authors");
|
|
if (!$result) {
|
|
echo "Erreur durant la requête.\n";
|
|
exit;
|
|
}
|
|
|
|
$arr = pg_fetch_array ($result, 0, PGSQL_NUM);
|
|
echo $arr[0] . " <- array\n";
|
|
|
|
$arr = pg_fetch_array ($result, 1, PGSQL_ASSOC);
|
|
echo $arr["author"] . " <- array\n";
|
|
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
<note>
|
|
<para>
|
|
Depuis 4.1.0, <parameter>row</parameter> est devenu optionnel.
|
|
Appeler <function>pg_fetch_array</function> incrémentera
|
|
le pointeur interne de 1.
|
|
</para>
|
|
</note>
|
|
<para>
|
|
Voir aussi
|
|
<function>pg_fetch_row</function>,
|
|
<function>pg_fetch_object</function> et
|
|
<function>pg_fetch_result</function>.
|
|
</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:"../../../../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
|
|
-->
|