mirror of
https://github.com/php/doc-it.git
synced 2026-03-24 23:52:12 +01:00
git-svn-id: https://svn.php.net/repository/phpdoc/it/trunk@314554 c90b9560-bf6c-de11-be94-00142212c4b1
141 lines
4.5 KiB
XML
141 lines
4.5 KiB
XML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!-- splitted from ./it/functions/pgsql.xml, last change in rev 1.10 -->
|
|
<!-- last change to 'pg-fetch-object' in en/ tree in rev 1.2 -->
|
|
<!-- EN-Revision: n/a Maintainer: cucinato Status: ready -->
|
|
<!-- OLD-Revision: 1.70/EN.1.2 -->
|
|
<!-- CREDITS: fabio,cortesi,denny -->
|
|
<refentry xml:id="function.pg-fetch-object" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>pg_fetch_object</refname>
|
|
<refpurpose>Carica una tupla in un oggetto</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Descrizione</title>
|
|
<methodsynopsis>
|
|
<type>object</type><methodname>pg_fetch_object</methodname>
|
|
<methodparam><type>resource</type><parameter>result</parameter></methodparam>
|
|
<methodparam choice="opt"><type>int</type><parameter>tupla</parameter></methodparam>
|
|
<methodparam choice="opt"><type>int</type><parameter>tipo_risultato</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
<function>pg_fetch_object</function> restituisce un oggetto avente
|
|
le proprietà che corrispondono alla tupla scaricata. Restituisce &false;
|
|
se non ci sono più tuple o in caso di errore.
|
|
</para>
|
|
<para>
|
|
<function>pg_fetch_object</function> è simile a
|
|
<function>pg_fetch_array</function>, con una differenza - viene
|
|
restituito un oggetto invece che un array. Indirettamente, questo significa
|
|
che si può accedere ai dati solo attraverso i nomi dei campi, e non attraverso
|
|
i loro indici numerici (i nomi delle proprietà non possono essere numeri).
|
|
</para>
|
|
<para>
|
|
<parameter>tupla</parameter> è il numero della riga (record) da
|
|
caricare. La prima tupla è la numero 0.
|
|
</para>
|
|
<para>
|
|
Per quanto riguarda la velocità di esecuzione, questa funzione è identica
|
|
a <function>pg_fetch_array</function>, ed è veloce quasi quanto
|
|
<function>pg_fetch_row</function> (la differenza è
|
|
trascurabile).
|
|
</para>
|
|
<note>
|
|
<para>
|
|
Dalla versione 4.1.0, <parameter>tupla</parameter> è opzionale.
|
|
</para>
|
|
<para>
|
|
Dalla versione 4.3.0, <parameter>tipo_risultato</parameter> è di default a PGSQL_ASSOC mentre
|
|
il default delle versioni precedenti era PGSQL_BOTH. La proprietà numerica è inutile,
|
|
dal momento che un nome di proprietà numerico non è valido in PHP.
|
|
</para>
|
|
<para>
|
|
<parameter>tipo_risultato</parameter> potrebbe essere abbandonato nelle versioni future.
|
|
</para>
|
|
</note>
|
|
<para>
|
|
<example>
|
|
<title>Postgres fetch object</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$database = "verlag";
|
|
$db_conn = pg_connect ("host=localhost port=5432 dbname=$database");
|
|
if (!$db_conn): ?>
|
|
<H1>Failed connecting to postgres database <?php echo $database ?></H1> <?php
|
|
exit;
|
|
endif;
|
|
|
|
$qu = pg_exec ($db_conn, "SELECT * FROM verlag ORDER BY autor");
|
|
$row = 0; // postgres needs a row counter other dbs might not
|
|
|
|
while ($data = pg_fetch_object ($qu, $row)) {
|
|
echo $data->autor." (";
|
|
echo $data->jahr ."): ";
|
|
echo $data->titel."<BR>";
|
|
$row++;
|
|
}
|
|
?>
|
|
<PRE>
|
|
<?php
|
|
$fields[] = Array ("autor", "Author");
|
|
$fields[] = Array ("jahr", " Year");
|
|
$fields[] = Array ("titel", " Title");
|
|
|
|
$row= 0; // postgres needs a row counter other dbs might not
|
|
while ($data = pg_fetch_object ($qu, $row)) {
|
|
echo "----------\n";
|
|
reset ($fields);
|
|
while (list (,$item) = each ($fields)):
|
|
echo $item[1].": ".$data->$item[0]."\n";
|
|
endwhile;
|
|
$row++;
|
|
}
|
|
echo "----------\n";
|
|
?>
|
|
</PRE>
|
|
<?php
|
|
pg_freeresult ($qu);
|
|
pg_close ($db_conn);
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
Vedere anche
|
|
<function>pg_query</function>,
|
|
<function>pg_fetch_array</function>,
|
|
<function>pg_fetch_row</function> e
|
|
<function>pg_fetch_result</function>.
|
|
</para>
|
|
<note>
|
|
<para>
|
|
Dalla versione 4.1.0, <parameter>row</parameter> è diventato opzionale.
|
|
La chiamata alla <function>pg_fetch_object</function> incrementa
|
|
di 1 il contatore di riga interno.
|
|
</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:"~/.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
|
|
-->
|