mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-19 10:28:54 +00:00

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@117504 c90b9560-bf6c-de11-be94-00142212c4b1
117 lines
3.6 KiB
XML
117 lines
3.6 KiB
XML
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!-- $Revision: 1.7 $ -->
|
|
<!-- 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 an optional parameter that controls
|
|
how the return value is initialized.
|
|
<parameter>result_type</parameter> is a constant and can take the
|
|
following values: <constant>PGSQL_ASSOC</constant>,
|
|
<constant>PGSQL_NUM</constant>, and <constant>PGSQL_BOTH</constant>.
|
|
<function>pg_fetch_array</function> returns associative array
|
|
that has field name as key for <constant>PGSQL_ASSOC</constant>, field index as key
|
|
with <constant>PGSQL_NUM</constant> and both field name/index as key with
|
|
<constant>PGSQL_BOTH</constant>. Default is <constant>PGSQL_BOTH</constant>.
|
|
<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>
|
|
<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>
|
|
<para>
|
|
See also
|
|
<function>pg_fetch_row</function>,
|
|
<function>pg_fetch_object</function> and
|
|
<function>pg_fetch_result</function>.
|
|
</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
|
|
-->
|