<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.5 $ -->
<!-- splitted from ./en/functions/pgsql.xml, last change in rev 1.2 -->
  <refentry id="function.pg-fetch-array">
   <refnamediv>
    <refname>pg_fetch_array</refname>
    <refpurpose>Fetch a row as an array</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> returns an array that
     corresponds to the fetched row (tuples/records). It returns
     &false;, if there are no more rows.
    </para>
    <para>
     <function>pg_fetch_array</function> is an extended version of
     <function>pg_fetch_row</function>.  In addition to storing the
     data in the numeric indices (field index) to the result array, it
     also stores the data in associative indices (field name) by
     default.
    </para>
    <para>
     <parameter>row</parameter> is row (record) number to be
     retrieved. First row is 0.
    </para>
    <para>
     <parameter>result_type</parameter> is optional parameter controls
     how return value is initialized.
     <parameter>result_type</parameter> is a constant and can take the
     following values: PGSQL_ASSOC, PGSQL_NUM, and PGSQL_BOTH.
     <function>pg_fetch_array</function> returns associative array
     that has field name as key for PGSQL_ASSOC. field index as key
     with PGSQL_NUM and both field name/index as key with
     PGSQL_BOTH. Default is PGSQL_BOTH.
     <note>
      <para>
       <parameter>result_type</parameter> was added in PHP 4.0.
      </para>
     </note>
    </para>
    <para>
     <function>pg_fetch_array</function> is NOT significantly
     slower than using <function>pg_fetch_row</function>, while it
     provides a significant ease of use.
    </para>
    <para>
     See also <function>pg_fetch_row</function> and
    <function>pg_fetch_object</function> and
    <function>pg_fetch_result</function>.
    </para>
    <para>
     <example>
      <title>PostgreSQL fetch array</title>
      <programlisting role="php">
<![CDATA[
<?php 
$conn = pg_pconnect ("dbname=publisher");
if (!$conn) {
    echo "An error occured.\n";
    exit;
}

$result = pg_query ($conn, "SELECT * FROM authors");
if (!$result) {
    echo "An error occured.\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>
      From 4.1.0, <parameter>row</parameter> became optional.
      Calling <function>pg_fetch_array</function> will increment
      internal row counter by 1.
     </para>
    </note>
   </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
-->