mirror of
https://github.com/php/doc-es.git
synced 2026-03-24 15:32:36 +01:00
177 lines
5.1 KiB
XML
177 lines
5.1 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- EN-Revision: cfeb14a38b666f6a3fc73da70f4a90fbe115e53f Maintainer: PhilDaiguille Status: ready -->
|
|
<!-- Reviewed: no -->
|
|
<refentry xml:id="function.pg-fetch-array" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>pg_fetch_array</refname>
|
|
<refpurpose>
|
|
Lee una línea de resultado PostgreSQL en un array
|
|
</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type class="union"><type>array</type><type>false</type></type><methodname>pg_fetch_array</methodname>
|
|
<methodparam><type>PgSql\Result</type><parameter>result</parameter></methodparam>
|
|
<methodparam choice="opt"><type class="union"><type>int</type><type>null</type></type><parameter>row</parameter><initializer>&null;</initializer></methodparam>
|
|
<methodparam choice="opt"><type>int</type><parameter>mode</parameter><initializer><constant>PGSQL_BOTH</constant></initializer></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
<function>pg_fetch_array</function> devuelve un array que contiene
|
|
la línea solicitada.
|
|
</para>
|
|
<para>
|
|
<function>pg_fetch_array</function> es una versión mejorada de
|
|
<function>pg_fetch_row</function>. Además de proporcionar un array con
|
|
índice numérico, también puede almacenar los datos en un array asociativo,
|
|
utilizando los nombres de los campos como claves. Estas dos funciones utilizan
|
|
el array asociativo por omisión.
|
|
</para>
|
|
&database.fetch-null;
|
|
<para>
|
|
<function>pg_fetch_array</function> no es significativamente más lenta
|
|
que <function>pg_fetch_row</function> y aporta una comodidad de uso apreciable.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>result</parameter></term>
|
|
<listitem>
|
|
&pgsql.parameter.result;
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>row</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Número de la línea a recuperar. Las líneas están numeradas
|
|
comenzando por 0. Si el argumento es omitido o si vale &null;,
|
|
se recupera la línea siguiente.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>mode</parameter></term>
|
|
<listitem>
|
|
&pgsql.parameter.mode;
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
Un array con índice numérico (comenzando por 0), asociativo (indexado con
|
|
el nombre de los campos) o ambos.
|
|
Cada valor en el array está representado como un string
|
|
(&string;). Los valores &null; de la base de datos son
|
|
devueltos como &null;.
|
|
</para>
|
|
<para>
|
|
&false; es devuelto si <parameter>row</parameter> excede el número de
|
|
líneas en el conjunto de resultados, no hay más líneas disponibles o cualquier
|
|
otro error.
|
|
Intentar recuperar el resultado de una consulta que no sea SELECT también devolverá &false;.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="changelog">
|
|
&reftitle.changelog;
|
|
<informaltable>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>&Version;</entry>
|
|
<entry>&Description;</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
&pgsql.changelog.result-object;
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title>Ejemplo con <function>pg_fetch_array</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
|
|
$conn = pg_pconnect ("dbname=publisher");
|
|
if (!$conn) {
|
|
echo "Error de conexión.\n";
|
|
exit;
|
|
}
|
|
|
|
$result = pg_query ($conn, "SELECT autor, email FROM autores");
|
|
if (!$result) {
|
|
echo "Error durante la consulta.\n";
|
|
exit;
|
|
}
|
|
|
|
$arr = pg_fetch_array ($result, 0, PGSQL_NUM);
|
|
echo $arr[0] . " <- Línea 1 Autor\n";
|
|
echo $arr[1] . " <- Línea 1 Correo electrónico\n";
|
|
|
|
// El parámetro row es opcional; NULL puede ser pasado en su lugar,
|
|
// para pasar un modo. Las llamadas sucesivas a pg_fetch_array
|
|
// devolverán la línea siguiente.
|
|
$arr = pg_fetch_array($result, NULL, PGSQL_ASSOC);
|
|
echo $arr["autor"] . " <- Línea 2 Autor\n";
|
|
echo $arr["email"] . " <- Línea 2 Correo electrónico\n";
|
|
|
|
$arr = pg_fetch_array($result);
|
|
echo $arr["autor"] . " <- Línea 3 Autor\n";
|
|
echo $arr[1] . " <- Línea 3 Correo electrónico\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
|
|
-->
|