[PHP-DOC] cvs: phpdoc /it/functions pgsql.xml From: Luca Perugini (l.perugini <email protected>)
Date: 07/15/00

perugini Sat Jul 15 00:47:05 2000 EDT

  Modified files:
    /phpdoc/it/functions pgsql.xml
  Log:
  
  Section translated by
   Fabio Gandola <fabiogandola <email protected>>
  
  
Index: phpdoc/it/functions/pgsql.xml
diff -u phpdoc/it/functions/pgsql.xml:1.4 phpdoc/it/functions/pgsql.xml:1.5
--- phpdoc/it/functions/pgsql.xml:1.4 Tue Jul 11 17:10:39 2000
+++ phpdoc/it/functions/pgsql.xml Sat Jul 15 00:47:05 2000
@@ -1,1209 +1,1208 @@
- <reference id="ref.pgsql">
- <title>PostgreSQL functions</title>
- <titleabbrev>PostgreSQL</titleabbrev>
-
- <partintro>
- <para>
- Postgres, developed originally in the UC Berkeley Computer Science
- Department, pioneered many of the object-relational concepts now
- becoming available in some commercial databases. It provides
- SQL92/SQL3 language support, transaction integrity, and type
- extensibility. PostgreSQL is a public-domain, open source
- descendant of this original Berkeley code.
- </para>
- <para>
- PostgreSQL is available without cost. The current version is
- available at <ulink url="&url.pgsql;">www.PostgreSQL.org</ulink>.
- </para>
- <para>
- Since version 6.3 (03/02/1998) PostgreSQL uses unix domain sockets.
- A table is shown below describing these new connection possibilities.
- This socket will be found in <filename>/tmp/.s.PGSQL.5432</filename>.
- This option can be enabled with the '-i' flag to <command>postmaster
- </command> and it's meaning is: "listen on TCP/IP sockets as well as
- Unix domain sockets".
- <table>
- <title>Postmaster and PHP</title>
- <tgroup cols="3">
- <thead>
- <row>
- <entry>Postmaster</entry>
- <entry>PHP</entry>
- <entry>Status</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry>postmaster &amp;</entry>
- <entry>pg_connect("", "", "", "", "dbname");</entry>
- <entry>OK</entry>
- </row>
- <row>
- <entry>postmaster -i &amp;</entry>
- <entry>pg_connect("", "", "", "", "dbname");</entry>
- <entry>OK</entry>
- </row>
- <row>
- <entry>postmaster &amp;</entry>
- <entry>pg_connect("localhost", "", "", "", "dbname");</entry>
- <entry>
- Unable to connect to PostgreSQL server: connectDB() failed:
- Is the postmaster running and accepting TCP/IP (with -i)
- connection at 'localhost' on port '5432'? in
- /path/to/file.php3 on line 20.
- </entry>
- </row>
- <row>
- <entry>postmaster -i &amp;</entry>
- <entry>pg_connect("localhost", "", "", "", "dbname");</entry>
- <entry>OK</entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- </para>
- <para>
- One can also establish a connection with the following command:
- <command>$conn = pg_Connect("host=localhost port=5432
- dbname=chris");</command>
- </para>
- <para>
- To use the large object (lo) interface, it is necessary to enclose
- it within a transaction block. A transaction block starts with a
- <command>begin</command> and if the transaction was valid ends
- with <command>commit</command> or <command>end</command>. If the
- transaction fails the transaction should be closed with
- <command>rollback</command> or <command>abort</command>.
-
- <example>
- <title>Using Large Objects</title>
- <programlisting role="php">
-&lt;?php
- $database = pg_Connect ("", "", "", "", "jacarta");
- pg_exec ($database, "begin");
- $oid = pg_locreate ($database);
- echo ("$oid\n");
- $handle = pg_loopen ($database, $oid, "w");
- echo ("$handle\n");
- pg_lowrite ($handle, "gaga");
- pg_loclose ($handle);
- pg_exec ($database, "commit");
-?>
- </programlisting>
- </example>
- </para>
- </partintro>
-
- <refentry id="function.pg-close">
- <refnamediv>
- <refname>pg_Close</refname>
- <refpurpose>closes a PostgreSQL connection</refpurpose>
- </refnamediv>
- <refsect1>
- <title>Description</title>
- <funcsynopsis>
- <funcprototype>
- <funcdef>bool <function>pg_close</function></funcdef>
- <paramdef>int <parameter>connection</parameter></paramdef>
- </funcprototype>
- </funcsynopsis>
- <para>
- Returns false if connection is not a valid connection index, true
- otherwise. Closes down the connection to a PostgreSQL database
- associated with the given connection index.
- </para>
- </refsect1>
- </refentry>
-
- <refentry id="function.pg-cmdtuples">
- <refnamediv>
- <refname>pg_cmdTuples</refname>
- <refpurpose>returns number of affected tuples</refpurpose>
- </refnamediv>
- <refsect1>
- <title>Description</title>
- <funcsynopsis>
- <funcprototype>
- <funcdef>int <function>pg_cmdtuples</function></funcdef>
- <paramdef>int <parameter>result_id</parameter></paramdef>
- </funcprototype>
- </funcsynopsis>
- <para>
- <function>pg_cmdTuples</function> returns the number of tuples
- (instances) affected by INSERT, UPDATE, and DELETE queries. If no
- tuple is affected the function will return 0.
- <example>
- <title>pg_cmdtuples</title>
- <programlisting role="php">
-&lt;?php
-$result = pg_exec($conn, "INSERT INTO verlag VALUES ('Autor')");
-$cmdtuples = pg_cmdtuples($result);
-echo $cmdtuples . " &lt;- cmdtuples affected.";
-?>
- </programlisting>
- </example>
- </para>
- </refsect1>
- </refentry>
-
- <refentry id="function.pg-connect">
- <refnamediv>
- <refname>pg_Connect</refname>
- <refpurpose>opens a connection</refpurpose>
- </refnamediv>
- <refsect1>
- <title>Description</title>
- <funcsynopsis>
- <funcprototype>
- <funcdef>int <function>pg_connect</function></funcdef>
- <paramdef>string <parameter>host</parameter></paramdef>
- <paramdef>string <parameter>port</parameter></paramdef>
- <paramdef>string <parameter>options</parameter></paramdef>
- <paramdef>string <parameter>tty</parameter></paramdef>
- <paramdef>string <parameter>dbname</parameter></paramdef>
- </funcprototype>
- </funcsynopsis>
- <para>
- Returns a connection index on success, or false if the connection
- could not be made. Opens a connection to a PostgreSQL
- database. Each of the arguments should be a quoted string,
- including the port number. The options and tty arguments are
- optional and can be left out. This function returns a connection
- index that is needed by other PostgreSQL functions. You can have
- multiple connections open at once.
- </para>
- <para>
- A connection can also established with the following command:
- <command>$conn = pg_connect("dbname=marliese port=5432");</command>
- Other parameters besides <parameter>dbname</parameter> and
- <parameter>port</parameter> are <parameter>host</parameter>,
- <parameter>tty</parameter>, <parameter>options</parameter>,
- <parameter>user</parameter> and <parameter>password</parameter>.
- </para>
- <para>
- See also <function>pg_pConnect</function>.
- </para>
- </refsect1>
- </refentry>
-
- <refentry id="function.pg-dbname">
- <refnamediv>
- <refname>pg_DBname</refname>
- <refpurpose>database name</refpurpose>
- </refnamediv>
- <refsect1>
- <title>Description</title>
- <funcsynopsis>
- <funcprototype>
- <funcdef>string <function>pg_dbname</function></funcdef>
- <paramdef>int <parameter>connection</parameter></paramdef>
- </funcprototype>
- </funcsynopsis>
- <para>
- Returns the name of the database that the given PostgreSQL
- connection index is connected to, or false if connection is not a
- valid connection index.
- </para>
- </refsect1>
- </refentry>
-
- <refentry id="function.pg-errormessage">
- <refnamediv>
- <refname>pg_ErrorMessage</refname>
- <refpurpose>error message</refpurpose>
- </refnamediv>
- <refsect1>
- <title>Description</title>
- <funcsynopsis>
- <funcprototype>
- <funcdef>string <function>pg_errormessage</function></funcdef>
- <paramdef>int <parameter>connection</parameter></paramdef>
- </funcprototype>
- </funcsynopsis>
- <para>
- Returns a string containing the error message, false on failure.
- Details about the error probably cannot be retrieved using the
- <function>pg_errormessage</function> function if an error occured
- on the last database action for which a valid connection exists,
- this function will return a string containing the error message
- generated by the backend server.
- </para>
- </refsect1>
- </refentry>
-
- <refentry id="function.pg-exec">
- <refnamediv>
- <refname>pg_Exec</refname>
- <refpurpose>execute a query</refpurpose>
- </refnamediv>
- <refsect1>
- <title>Description</title>
- <funcsynopsis>
- <funcprototype>
- <funcdef>int <function>pg_exec</function></funcdef>
- <paramdef>int <parameter>connection</parameter></paramdef>
- <paramdef>string <parameter>query</parameter></paramdef>
- </funcprototype>
- </funcsynopsis>
- <para>
- Returns a result index if query could be executed, false on
- failure or if connection is not a valid connection index. Details
- about the error can be retrieved using the
- <function>pg_ErrorMessage</function> function if connection is
- valid. Sends an SQL statement to the PostgreSQL database
- specified by the connection index. The connection must be a valid
- index that was returned by <function>pg_Connect</function>. The
- return value of this function is an index to be used to access
- the results from other PostgreSQL functions.
- <note>
- <simpara>
- PHP/FI returned 1 if the query was not expected to return data
- (inserts or updates, for example) and greater than 1 even on
- selects that did not return anything. No such assumption can be
- made in PHP.
- </simpara>
- </note>
- </para>
- </refsect1>
- </refentry>
-
- <refentry id="function.pg-fetch-array">
- <refnamediv>
- <refname>pg_Fetch_Array</refname>
- <refpurpose>fetch row as array</refpurpose>
- </refnamediv>
- <refsect1>
- <title>Description</title>
- <funcsynopsis>
- <funcprototype>
- <funcdef>array <function>pg_fetch_array</function></funcdef>
- <paramdef>int <parameter>result</parameter></paramdef>
- <paramdef>int <parameter>row</parameter></paramdef>
- <paramdef>int
- <parameter><optional>result_type</optional></parameter>
- </paramdef>
- </funcprototype>
- </funcsynopsis>
- <para>
- Returns: An array that corresponds to the fetched row, or 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 of the result array, it also stores
- the data in associative indices, using the field names as keys.
- </para>
- <para>
- The third optional argument <parameter>result_type</parameter> in
- <function>pg_fetch_array</function> is a constant and can take the
- following values: PGSQL_ASSOC, PGSQL_NUM, and PGSQL_BOTH.
- <note>
- <para>
- <parameter>Result_type</parameter> was added in PHP 4.0.
- </para>
- </note>
- </para>
- <para>
- An important thing to note is that using
- <function>pg_fetch_array</function> is NOT significantly
- slower than using <function>pg_fetch_row</function>, while it
- provides a significant added value.
- </para>
- <para>
- For further details, also see
- <function>pg_fetch_row</function>
- </para>
- <example>
- <title>PostgreSQL fetch array</title>
- <programlisting role="php">
-&lt;?php
-$conn = pg_pconnect("","","","","publisher");
-if (!$conn) {
- echo "An error occured.\n";
- exit;
-}
-
-$result = pg_Exec ($conn, "SELECT * FROM authors");
-if (!$result) {
- echo "An error occured.\n";
- exit;
-}
-
-$arr = pg_fetch_array ($result, 0);
-echo $arr[0] . " &lt;- array\n";
-
-$arr = pg_fetch_array ($result, 1);
-echo $arr["author"] . " &lt;- array\n";
-?>
- </programlisting>
- </example>
- </refsect1>
- </refentry>
-
- <refentry id="function.pg-fetch-object">
- <refnamediv>
- <refname>pg_Fetch_Object</refname>
- <refpurpose>fetch row as object</refpurpose>
- </refnamediv>
- <refsect1>
- <title>Description</title>
- <funcsynopsis>
- <funcprototype>
- <funcdef>object <function>pg_fetch_object</function></funcdef>
- <paramdef>int <parameter>result</parameter></paramdef>
- <paramdef>int <parameter>row</parameter></paramdef>
- <paramdef>int
- <parameter><optional>result_type</optional></parameter>
- </paramdef>
- </funcprototype>
- </funcsynopsis>
- <para>
- Returns: An object with properties that correspond to the fetched
- row, or false if there are no more rows.
- </para>
- <para>
- <function>pg_fetch_object</function> is similar to
- <function>pg_fetch_array</function>, with one difference - an
- object is returned, instead of an array. Indirectly, that means
- that you can only access the data by the field names, and not by
- their offsets (numbers are illegal property names).
- </para>
- <para>
- The third optional argument <parameter>result_type</parameter> in
- <function>pg_fetch_object</function> is a constant and can take the
- following values: PGSQL_ASSOC, PGSQL_NUM, and PGSQL_BOTH.
- <note>
- <para>
- <parameter>Result_type</parameter> was added in PHP 4.0.
- </para>
- </note>
- </para>
- <para>
- Speed-wise, the function is identical to
- <function>pg_fetch_array</function>, and almost as quick as
- <function>pg_fetch_row</function> (the difference is
- insignificant).
- </para>
- <para>
- See also: <function>pg_fetch_array</function> and
- <function>pg_fetch_row</function>.
- <example>
- <title>Postgres fetch object</title>
- <programlisting role="php">
-&lt;?php
-$database = "verlag";
-$db_conn = pg_connect ("localhost", "5432", "", "", $database);
-if (!$db_conn): ?>
- &lt;H1>Failed connecting to postgres database &lt;? echo $database ?>&lt;/H1> &lt;?
- 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."&lt;BR>";
- $row++;
-endwhile; ?>
-
-&lt;PRE>&lt;?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++;
-endwhile;
-echo "----------\n"; ?>
-&lt;/PRE> &lt;?php
-pg_freeResult ($qu);
-pg_close ($db_conn);
-?>
- </programlisting>
- </example>
- </para>
- </refsect1>
- </refentry>
-
- <refentry id="function.pg-fetch-row">
- <refnamediv>
- <refname>pg_Fetch_Row</refname>
- <refpurpose>get row as enumerated array</refpurpose>
- </refnamediv>
- <refsect1>
- <title>Description</title>
- <funcsynopsis>
- <funcprototype>
- <funcdef>array <function>pg_fetch_row</function></funcdef>
- <paramdef>int <parameter>result</parameter></paramdef>
- <paramdef>int <parameter>row</parameter></paramdef>
- </funcprototype>
- </funcsynopsis>
- <para>
- Returns: An array that corresponds to the fetched row, or false
- if there are no more rows.
- </para>
- <para>
- <function>pg_fetch_row</function> fetches one row of data from
- the result associated with the specified result identifier. The
- row is returned as an array. Each result column is stored in an
- array offset, starting at offset 0.
- </para>
- <para>
- Subsequent call to <function>pg_fetch_row</function> would
- return the next row in the result set, or false if there are no
- more rows.
- </para>
- <para>
- See also: <function>pg_fetch_array</function>,
- <function>pg_fetch_object</function>,
- <function>pg_result</function>.
- <example>
- <title>Postgres fetch row</title>
- <programlisting role="php">
-&lt;?php
-$conn = pg_pconnect("","","","","publisher");
-if (!$conn) {
- echo "An error occured.\n";
- exit;
-}
-
-$result = pg_Exec ($conn, "SELECT * FROM authors");
-if (!$result) {
- echo "An error occured.\n";
- exit;
-}
-
-$row = pg_fetch_row ($result, 0);
-echo $row[0] . " &lt;- row\n";
-
-$row = pg_fetch_row ($result, 1);
-echo $row[0] . " &lt;- row\n";
-
-$row = pg_fetch_row ($result, 2);
-echo $row[1] . " &lt;- row\n";
-?>
- </programlisting>
- </example>
- </para>
- </refsect1>
- </refentry>
-
- <refentry id="function.pg-fieldisnull">
- <refnamediv>
- <refname>pg_FieldIsNull</refname>
- <refpurpose>Test if a field is NULL</refpurpose>
- </refnamediv>
- <refsect1>
- <title>Description</title>
- <funcsynopsis>
- <funcprototype>
- <funcdef>int <function>pg_fieldisnull</function></funcdef>
- <paramdef>int <parameter>result_id</parameter></paramdef>
- <paramdef>int <parameter>row</parameter></paramdef>
- <paramdef>mixed <parameter>field</parameter></paramdef>
- </funcprototype>
- </funcsynopsis>
- <para>
- Test if a field is NULL or not. Returns 0 if the field in the
- given row is not NULL. Returns 1 if the field in the given row is
- NULL. Field can be specified as number or fieldname. Row
- numbering starts at 0.
- </para>
- </refsect1>
- </refentry>
-
- <refentry id="function.pg-fieldname">
- <refnamediv>
- <refname>pg_FieldName</refname>
- <refpurpose>Returns the name of a field</refpurpose>
- </refnamediv>
- <refsect1>
- <title>Description</title>
- <funcsynopsis>
- <funcprototype>
- <funcdef>string <function>pg_fieldname</function></funcdef>
- <paramdef>int <parameter>result_id</parameter></paramdef>
- <paramdef>int <parameter>field_number</parameter></paramdef>
- </funcprototype>
- </funcsynopsis>
- <para>
- <function>pg_FieldName</function> will return the name of the
- field occupying the given column number in the given PostgreSQL
- result identifier. Field numbering starts from 0.
- </para>
- </refsect1>
- </refentry>
-
- <refentry id="function.pg-fieldnum">
- <refnamediv>
- <refname>pg_FieldNum</refname>
- <refpurpose>Returns the number of a column</refpurpose>
- </refnamediv>
- <refsect1>
- <title>Description</title>
- <funcsynopsis>
- <funcprototype>
- <funcdef>int <function>pg_fieldnum</function></funcdef>
- <paramdef>int <parameter>result_id</parameter></paramdef>
- <paramdef>string <parameter>field_name</parameter></paramdef>
- </funcprototype>
- </funcsynopsis>
- <para>
- <function>pg_FieldNum</function> will return the number of the
- column slot that corresponds to the named field in the given
- PosgreSQL result identifier. Field numbering starts at 0. This
- function will return -1 on error.
- </para>
- </refsect1>
- </refentry>
-
- <refentry id="function.pg-fieldprtlen">
- <refnamediv>
- <refname>pg_FieldPrtLen</refname>
- <refpurpose>Returns the printed length</refpurpose>
- </refnamediv>
- <refsect1>
- <title>Description</title>
- <funcsynopsis>
- <funcprototype>
- <funcdef>int <function>pg_fieldprtlen</function></funcdef>
- <paramdef>int <parameter>result_id</parameter></paramdef>
- <paramdef>int <parameter>row_number</parameter></paramdef>
- <paramdef>string <parameter>field_name</parameter></paramdef>
- </funcprototype>
- </funcsynopsis>
- <para>
- <function>pg_FieldPrtLen</function> will return the actual
- printed length (number of characters) of a specific value in a
- PostgreSQL result. Row numbering starts at 0. This function
- will return -1 on an error.
- </para>
- </refsect1>
- </refentry>
-
- <refentry id="function.pg-fieldsize">
- <refnamediv>
- <refname>pg_FieldSize</refname>
- <refpurpose>
- Returns the internal storage size of the named field
- </refpurpose>
- </refnamediv>
- <refsect1>
- <title>Description</title>
- <funcsynopsis>
- <funcprototype>
- <funcdef>int <function>pg_fieldsize</function></funcdef>
- <paramdef>int <parameter>result_id</parameter></paramdef>
- <paramdef>int <parameter>field_number</parameter></paramdef>
- </funcprototype>
- </funcsynopsis>
- <para>
- <function>pg_FieldSize</function> will return the internal
- storage size (in bytes) of the field number in the given
- PostgreSQL result. Field numbering starts at 0. A field size of
- -1 indicates a variable length field. This function will return
- false on error.
- </para>
- </refsect1>
- </refentry>
-
- <refentry id="function.pg-fieldtype">
- <refnamediv>
- <refname>pg_FieldType</refname>
- <refpurpose>
- Returns the type name for the corresponding field number
- </refpurpose>
- </refnamediv>
- <refsect1>
- <title>Description</title>
- <funcsynopsis>
- <funcprototype>
- <funcdef>int <function>pg_fieldtype</function></funcdef>
- <paramdef>int <parameter>result_id</parameter></paramdef>
- <paramdef>int <parameter>field_number</parameter></paramdef>
- </funcprototype>
- </funcsynopsis>
- <para>
- <function>pg_FieldType</function> will return a string containing
- the type name of the given field in the given PostgreSQL result
- identifier. Field numbering starts at 0.
- </para>
- </refsect1>
- </refentry>
-
- <refentry id="function.pg-freeresult">
- <refnamediv>
- <refname>pg_FreeResult</refname>
- <refpurpose>Frees up memory</refpurpose>
- </refnamediv>
- <refsect1>
- <title>Description</title>
- <funcsynopsis>
- <funcprototype>
- <funcdef>int <function>pg_freeresult</function></funcdef>
- <paramdef>int <parameter>result_id</parameter></paramdef>
- </funcprototype>
- </funcsynopsis>
- <para>
- <function>pg_FreeResult</function> only needs to be called if you
- are worried about using too much memory while your script is
- running. All result memory will automatically be freed when the
- script is finished. But, if you are sure you are not going to
- need the result data anymore in a script, you may call
- <function>pg_FreeResult</function> with the result identifier as
- an argument and the associated result memory will be freed.
- </para>
- </refsect1>
- </refentry>
-
- <refentry id="function.pg-getlastoid">
- <refnamediv>
- <refname>pg_GetLastOid</refname>
- <refpurpose>Returns the last object identifier</refpurpose>
- </refnamediv>
- <refsect1>
- <title>Description</title>
- <funcsynopsis>
- <funcprototype>
- <funcdef>int <function>pg_getlastoid</function></funcdef>
- <paramdef>int <parameter>result_id</parameter></paramdef>
- </funcprototype>
- </funcsynopsis>
- <para>
- <function>pg_GetLastOid</function> can be used to retrieve the
- Oid assigned to an inserted tuple if the result identifier is
- used from the last command sent via <function>pg_Exec</function>
- and was an SQL INSERT. This function will return a positive
- integer if there was a valid Oid. It will return -1 if an error
- occured or the last command sent via <function>pg_Exec</function>
- was not an INSERT.
- </para>
- </refsect1>
- </refentry>
-
- <refentry id="function.pg-host">
- <refnamediv>
- <refname>pg_Host</refname>
- <refpurpose>Returns the host name</refpurpose>
- </refnamediv>
- <refsect1>
- <title>Description</title>
- <funcsynopsis>
- <funcprototype>
- <funcdef>string <function>pg_host</function></funcdef>
- <paramdef>int <parameter>connection_id</parameter></paramdef>
- </funcprototype>
- </funcsynopsis>
- <para>
- <function>pg_Host</function> will return the host name of the
- given PostgreSQL connection identifier is connected to.
- </para>
- </refsect1>
- </refentry>
-
- <refentry id="function.pg-loclose">
- <refnamediv>
- <refname>pg_loclose</refname>
- <refpurpose>close a large object</refpurpose>
- </refnamediv>
- <refsect1>
- <title>Description</title>
- <funcsynopsis>
- <funcprototype>
- <funcdef>void <function>pg_loclose</function></funcdef>
- <paramdef>int <parameter>fd</parameter></paramdef>
- </funcprototype>
- </funcsynopsis>
- <para>
- <function>pg_loclose</function> closes an Inversion Large
- Object. <parameter>fd</parameter> is a file descriptor for the
- large object from <function>pg_loopen</function>.
- </para>
- </refsect1>
- </refentry>
-
- <refentry id="function.pg-locreate">
- <refnamediv>
- <refname>pg_locreate</refname>
- <refpurpose>create a large object</refpurpose>
- </refnamediv>
- <refsect1>
- <title>Description</title>
- <funcsynopsis>
- <funcprototype>
- <funcdef>int <function>pg_locreate</function></funcdef>
- <paramdef>int <parameter>conn</parameter></paramdef>
- </funcprototype>
- </funcsynopsis>
- <para>
- <function>pg_locreate</function> creates an Inversion Large
- Object and returns the oid of the large object.
- <parameter>conn</parameter> specifies a valid database
- connection. PostgreSQL access modes INV_READ, INV_WRITE, and
- INV_ARCHIVE are not supported, the object is created always with
- both read and write access. INV_ARCHIVE has been removed from
- PostgreSQL itself (version 6.3 and above).
- </para>
- </refsect1>
- </refentry>
-
- <refentry id="function.pg-loexport">
- <refnamediv>
- <refname>pg_loexport</refname>
- <refpurpose>export a large object to file</refpurpose>
- </refnamediv>
- <refsect1>
- <title>Description</title>
- <funcsynopsis>
- <funcprototype>
- <funcdef>bool <function>pg_loexport</function></funcdef>
- <paramdef>int
- <parameter>oid</parameter>
- </paramdef>
- <paramdef>int
- <parameter>file</parameter>
- </paramdef>
- <paramdef>int
- <parameter><optional>connection_id</optional></parameter>
- </paramdef>
- </funcprototype>
- </funcsynopsis>
- <para>
- The <parameter>oid</parameter> argument specifies the object id
- of the large object to export and the <parameter>filename</parameter>
- argument specifies the pathname of the file. Returns FALSE if an error
- occurred, TRUE otherwise. Remember that handling large objects in
- PostgreSQL must happen inside a transaction.
- </para>
- </refsect1>
- </refentry>
-
- <refentry id="function.pg-loimport">
- <refnamediv>
- <refname>pg_loimport</refname>
- <refpurpose>import a large object from file</refpurpose>
- </refnamediv>
- <refsect1>
- <title>Description</title>
- <funcsynopsis>
- <funcprototype>
- <funcdef>int <function>pg_loimport</function></funcdef>
- <paramdef>int
- <parameter>file</parameter>
- </paramdef>
- <paramdef>int
- <parameter><optional>connection_id</optional></parameter>
- </paramdef>
- </funcprototype>
- </funcsynopsis>
- <para>
- The <parameter>filename</parameter> argument specifies the pathname
- of the file to be imported as a large object. Returns FALSE if an error
- occurred, object id of the just created large object otherwise. Remember
- that handling large objects in PostgreSQL must happen inside
- a transaction.
- </para>
- </refsect1>
- </refentry>
-
- <refentry id="function.pg-loopen">
- <refnamediv>
- <refname>pg_loopen</refname>
- <refpurpose>open a large object</refpurpose>
- </refnamediv>
- <refsect1>
- <title>Description</title>
- <funcsynopsis>
- <funcprototype>
- <funcdef>int <function>pg_loopen</function></funcdef>
- <paramdef>int <parameter>conn</parameter></paramdef>
- <paramdef>int <parameter>objoid</parameter></paramdef>
- <paramdef>string <parameter>mode</parameter></paramdef>
- </funcprototype>
- </funcsynopsis>
- <para>
- <function>pg_loopen</function> open an Inversion Large Object and
- returns file descriptor of the large object. The file descriptor
- encapsulates information about the connection. Do not close the
- connection before closing the large object file descriptor.
- <parameter>objoid</parameter> specifies a valid large object oid
- and <parameter>mode</parameter> can be either "r", "w", or "rw".
- </para>
- </refsect1>
- </refentry>
-
- <refentry id="function.pg-loread">
- <refnamediv>
- <refname>pg_loread</refname>
- <refpurpose>read a large object</refpurpose>
- </refnamediv>
- <refsect1>
- <title>Description</title>
- <funcsynopsis>
- <funcprototype>
- <funcdef>string <function>pg_loread</function></funcdef>
- <paramdef>int <parameter>fd</parameter></paramdef>
- <paramdef>int <parameter>len</parameter></paramdef>
- </funcprototype>
- </funcsynopsis>
- <para>
- <function>pg_loread</function> reads at most
- <parameter>len</parameter> bytes from a large object and
- returns it as a string.
- <parameter>fd</parameter> specifies a valid large object file
- descriptor and<parameter>len</parameter> specifies the maximum
- allowable size of the large object segment.
- </para>
- </refsect1>
- </refentry>
-
- <refentry id="function.pg-loreadall">
- <refnamediv>
- <refname>pg_loreadall</refname>
- <refpurpose>read a entire large object</refpurpose>
- </refnamediv>
- <refsect1>
- <title>Description</title>
- <funcsynopsis>
- <funcprototype>
- <funcdef>void <function>pg_loreadall</function></funcdef>
- <paramdef>int <parameter>fd</parameter></paramdef>
- </funcprototype>
- </funcsynopsis>
- <para>
- <function>pg_loreadall</function> reads a large object and
- passes it straight through to the browser after sending all pending
- headers. Mainly intended for sending binary data like images or sound.
- </para>
- </refsect1>
- </refentry>
-
- <refentry id="function.pg-lounlink">
- <refnamediv>
- <refname>pg_lounlink</refname>
- <refpurpose>delete a large object</refpurpose>
- </refnamediv>
- <refsect1>
- <title>Description</title>
- <funcsynopsis>
- <funcprototype>
- <funcdef>void <function>pg_lounlink</function></funcdef>
- <paramdef>int <parameter>conn</parameter></paramdef>
- <paramdef>int <parameter>lobjid</parameter></paramdef>
- </funcprototype>
- </funcsynopsis>
- <para>
- <function>pg_lounlink</function> deletes a large object with the
- <parameter>lobjid</parameter> identifier for that large object.
- </para>
- </refsect1>
- </refentry>
-
- <refentry id="function.pg-lowrite">
- <refnamediv>
- <refname>pg_lowrite</refname>
- <refpurpose>write a large object</refpurpose>
- </refnamediv>
- <refsect1>
- <title>Description</title>
- <funcsynopsis>
- <funcprototype>
- <funcdef>int <function>pg_lowrite</function></funcdef>
- <paramdef>int <parameter>fd</parameter></paramdef>
- <paramdef>string <parameter>buf</parameter></paramdef>
- </funcprototype>
- </funcsynopsis>
- <para>
- <function>pg_lowrite</function> writes at most to a large object
- from a variable <parameter>buf</parameter> and returns the number
- of bytes actually written, or false in the case of an error.
- <parameter>fd</parameter> is a file descriptor for the large
- object from <function>pg_loopen</function>.
- </para>
- </refsect1>
- </refentry>
-
- <refentry id="function.pg-numfields">
- <refnamediv>
- <refname>pg_NumFields</refname>
- <refpurpose>Returns the number of fields</refpurpose>
- </refnamediv>
- <refsect1>
- <title>Description</title>
- <funcsynopsis>
- <funcprototype>
- <funcdef>int <function>pg_numfields</function></funcdef>
- <paramdef>int <parameter>result_id</parameter></paramdef>
- </funcprototype>
- </funcsynopsis>
- <para>
- <function>pg_NumFields</function> will return the number of
- fields (columns) in a PostgreSQL result. The argument is a valid
- result identifier returned by <function>pg_Exec</function>. This
- function will return -1 on error.
- </para>
- </refsect1>
- </refentry>
-
- <refentry id="function.pg-numrows">
- <refnamediv>
- <refname>pg_NumRows</refname>
- <refpurpose>Returns the number of rows</refpurpose>
- </refnamediv>
- <refsect1>
- <title>Description</title>
- <funcsynopsis>
- <funcprototype>
- <funcdef>int <function>pg_numrows</function></funcdef>
- <paramdef>int <parameter>result_id</parameter></paramdef>
- </funcprototype>
- </funcsynopsis>
- <para>
- <function>pg_NumRows</function> will return the number of rows in a
- PostgreSQL result. The argument is a valid result identifier
- returned by <function>pg_Exec</function>. This function will
- return -1 on error.
- </para>
- </refsect1>
- </refentry>
-
- <refentry id="function.pg-options">
- <refnamediv>
- <refname>pg_Options</refname>
- <refpurpose>Returns options</refpurpose>
- </refnamediv>
- <refsect1>
- <title>Description</title>
- <funcsynopsis>
- <funcprototype>
- <funcdef>string <function>pg_options</function></funcdef>
- <paramdef>int <parameter>connection_id</parameter></paramdef>
- </funcprototype>
- </funcsynopsis>
- <para>
- <function>pg_Options</function> will return a string containing
- the options specified on the given PostgreSQL connection
- identifier.
- </para>
- </refsect1>
- </refentry>
-
- <refentry id="function.pg-pconnect">
- <refnamediv>
- <refname>pg_pConnect</refname>
- <refpurpose>
- Make a persistent database connection
- </refpurpose>
- </refnamediv>
- <refsect1>
- <title>Description</title>
- <funcsynopsis>
- <funcprototype>
- <funcdef>int <function>pg_pconnect</function></funcdef>
- <paramdef>string <parameter>host</parameter></paramdef>
- <paramdef>string <parameter>port</parameter></paramdef>
- <paramdef>string <parameter>options</parameter></paramdef>
- <paramdef>string <parameter>tty</parameter></paramdef>
- <paramdef>string <parameter>dbname</parameter></paramdef>
- </funcprototype>
- </funcsynopsis>
- <para>
- Returns a connection index on success, or false if the connection
- could not be made. Opens a persistent connection to a PostgreSQL
- database. Each of the arguments should be a quoted string,
- including the port number. The options and tty arguments are
- optional and can be left out. This function returns a connection
- index that is needed by other PostgreSQL functions. You can have
- multiple persistent connections open at once. See also
- <function>pg_Connect</function>.
- </para>
- <para>
- A connection can also established with the following command:
- <command>$conn = pg_pconnect("dbname=marliese port=5432");</command>
- Other parameters besides <parameter>dbname</parameter> and
- <parameter>port</parameter> are <parameter>host</parameter>,
- <parameter>tty</parameter>, <parameter>options</parameter>,
- <parameter>user</parameter> and <parameter>password</parameter>.
- </para>
- </refsect1>
- </refentry>
-
- <refentry id="function.pg-port">
- <refnamediv>
- <refname>pg_Port</refname>
- <refpurpose>Returns the port number</refpurpose>
- </refnamediv>
- <refsect1>
- <title>Description</title>
- <funcsynopsis>
- <funcprototype>
- <funcdef>int <function>pg_port</function></funcdef>
- <paramdef>int <parameter>connection_id</parameter></paramdef>
- </funcprototype>
- </funcsynopsis>
- <para>
- <function>pg_Port</function> will return the port number that the
- given PostgreSQL connection identifier is connected to.
- </para>
- </refsect1>
- </refentry>
-
- <refentry id="function.pg-result">
- <refnamediv>
- <refname>pg_Result</refname>
- <refpurpose>Returns values from a result identifier</refpurpose>
- </refnamediv>
- <refsect1>
- <title>Description</title>
- <funcsynopsis>
- <funcprototype>
- <funcdef>mixed <function>pg_result</function></funcdef>
- <paramdef>int <parameter>result_id</parameter></paramdef>
- <paramdef>int <parameter>row_number</parameter></paramdef>
- <paramdef>mixed <parameter>fieldname</parameter></paramdef>
- </funcprototype>
- </funcsynopsis>
- <para>
- <function>pg_Result</function> will return values from a result
- identifier produced by <function>pg_Exec</function>. The
- <parameter>row_number</parameter> and
- <parameter>fieldname</parameter> sepcify what cell in the table
- of results to return. Row numbering starts from 0. Instead of
- naming the field, you may use the field index as an unquoted
- number. Field indices start from 0.
- </para>
- <para>
- PostgreSQL has many built in types and only the basic ones are
- directly supported here. All forms of integer, boolean and oid
- types are returned as integer values. All forms of float, and
- real types are returned as double values. All other types,
- including arrays are returned as strings formatted in the same
- default PostgreSQL manner that you would see in the
- <command>psql</command> program.
- </para>
- </refsect1>
- </refentry>
-
- <refentry id="function.pg-trace">
- <refnamediv>
- <refname>pg_trace</refname>
- <refpurpose>Trace a connection to PostgreSQL server</refpurpose>
- </refnamediv>
- <refsect1>
- <title>Description</title>
- <funcsynopsis>
- <funcprototype>
- <funcdef>bool <function>pg_trace</function></funcdef>
- <paramdef>string
- <parameter>filename</parameter>
- </paramdef>
- <paramdef>string
- <parameter><optional>mode</optional></parameter>
- </paramdef>
- <paramdef>int
- <parameter><optional>connection</optional></parameter>
- </paramdef>
- </funcprototype>
- </funcsynopsis>
- <para>
- Enables tracing of the PostgreSQL frontend/backend communication
- to a debugging file. To fully understand the results one needs to be
- familiar with the internals of PostgreSQL communication protocol.
- For those who are not, it can still be useful for tracing errors in
- queries sent to the server, you could do for example
- 'grep '^To backend' trace.log' and see what queriew actually were sent
- to the PostgreSQL server.
- </para>
- <para>
- <parameter>filename</parameter> and <parameter>mode</parameter> are the
- same as in <function>fopen</function> (<parameter>mode</parameter> defaults
- to 'w'), <parameter>connection</parameter> specifies the connection to
- trace and defaults to the last one opened.
- </para>
- <para>
- Returns TRUE if <parameter>filename</parameter> could be opened for
- logging, FALSE otherwise.
- </para>
- <para>
- See also <function>fopen</function> and <function>pg_untrace</function>.
- </para>
- </refsect1>
- </refentry>
-
- <refentry id="function.pg-tty">
- <refnamediv>
- <refname>pg_tty</refname>
- <refpurpose>Returns the tty name</refpurpose>
- </refnamediv>
- <refsect1>
- <title>Description</title>
- <funcsynopsis>
- <funcprototype>
- <funcdef>string <function>pg_tty</function></funcdef>
- <paramdef>int <parameter>connection_id</parameter></paramdef>
- </funcprototype>
- </funcsynopsis>
- <para>
- <function>pg_tty</function> will return the tty name that server
- side debugging output is sent to on the given PostgreSQL
- connection identifier.
- </para>
- </refsect1>
- </refentry>
-
- <refentry id="function.pg-untrace">
- <refnamediv>
- <refname>pg_untrace</refname>
- <refpurpose>Stop tracing a connection to PostgreSQL server</refpurpose>
- </refnamediv>
- <refsect1>
- <title>Description</title>
- <funcsynopsis>
- <funcprototype>
- <funcdef>bool <function>pg_untrace</function></funcdef>
- <paramdef>int
- <parameter><optional>connection</optional></parameter>
- </paramdef>
- </funcprototype>
- </funcsynopsis>
- <para>
- Stop tracing started by <function>pg_trace</function>.
- <parameter>connection</parameter> specifies the connection that was
- traced and defaults to the last one opened.
- </para>
- <para>
- Returns always TRUE.
- </para>
- <para>
- See also <function>pg_trace</function>.
- </para>
- </refsect1>
- </refentry>
-
- </reference>
-
-<!-- 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
-sgml-parent-document:nil
-sgml-default-dtd-file:"../../manual.ced"
-sgml-exposed-tags:nil
-sgml-local-catalogs:nil
-sgml-local-ecat-files:nil
-End:
--->
+ <reference id="ref.pgsql">
+ <title>Funzioni PostgreSQL</title>
+ <titleabbrev>PostgreSQL</titleabbrev>
+
+ <partintro>
+ <para>
+ Postgres, originariamente sviluppato nel UC Berkeley Computer Science
+ Department, è stato uno dei pionieri dei concetti object-relational
+ che ora stanno diventando disponibili in alcuni database commerciali.
+ Fornisce supporto al linguaggio SQL92/SQL3, all'integrità delle transazioni,
+ e all'estensibilità del tipo. PostgreSQL è un discendente di dominio pubblico
+ e Open Source di questo codice Berkeley originale.
+ </para>
+ <para>
+ PostgreSQL è disponibile senza alcun costo. La versione corrente è
+ disponibile a <ulink url="&url.pgsql;">www.PostgreSQL.org</ulink>.
+ </para>
+ <para>
+ Fin dalla versione 6.3 (03/02/1998) PostgreSQL usa gli unix domain sockets.
+ La tabella sottostante descrive queste nuove possibilità di connessione.
+ Questo socket può essere trovato in <filename>/tmp/.s.PGSQL.5432</filename>.
+ Questa opzione può venire abilitata con la flag '-i' a <command>postmaster
+ </command> e il suo significato è: "ascolta sui sockets TCP/IP come sugli
+ Unix domain sockets".
+ <table>
+ <title>Postmaster e PHP</title>
+ <tgroup cols="3">
+ <thead>
+ <row>
+ <entry>Postmaster</entry>
+ <entry>PHP</entry>
+ <entry>Status</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>postmaster &amp;</entry>
+ <entry>pg_connect("", "", "", "", "dbname");</entry>
+ <entry>OK</entry>
+ </row>
+ <row>
+ <entry>postmaster -i &amp;</entry>
+ <entry>pg_connect("", "", "", "", "dbname");</entry>
+ <entry>OK</entry>
+ </row>
+ <row>
+ <entry>postmaster &amp;</entry>
+ <entry>pg_connect("localhost", "", "", "", "dbname");</entry>
+ <entry>
+ Impossibile collegarsi al server PostgreSQL: connectDB() failed:
+ Il postmaster è in esecuzione e accetta connessioni TCP/IP (con -i)
+ a 'localhost' sulla porta '5432'? in /path/to/file.php3 sulla linea 20.
+ </entry>
+ </row>
+ <row>
+ <entry>postmaster -i &amp;</entry>
+ <entry>pg_connect("localhost", "", "", "", "dbname");</entry>
+ <entry>OK</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ </para>
+ <para>
+ Si può anche stabilire una connessione con il seguete comando:
+ <command>$conn = pg_Connect("host=localhost port=5432
+ dbname=chris");</command>
+ </para>
+ <para>
+ Per usare l'interfaccia large object (lo), è necessario includerla entro
+ un blocco di una transazione. Un blocco di transazione inizia con un
+ <command>begin</command> e se la transazione è stata valida termina
+ con <command>commit</command> e <command>end</command>. Se la
+ transazione fallisce, essa deve venire chiusa con
+ <command>rollback</command> e <command>abort</command>.
+
+ <example>
+ <title>Utilizzare Large Objects</title>
+ <programlisting role="php">
+&lt;?php
+ $database = pg_Connect ("", "", "", "", "jacarta");
+ pg_exec ($database, "begin");
+ $oid = pg_locreate ($database);
+ echo ("$oid\n");
+ $handle = pg_loopen ($database, $oid, "w");
+ echo ("$handle\n");
+ pg_lowrite ($handle, "gaga");
+ pg_loclose ($handle);
+ pg_exec ($database, "commit");
+?>
+ </programlisting>
+ </example>
+ </para>
+ </partintro>
+
+ <refentry id="function.pg-close">
+ <refnamediv>
+ <refname>pg_Close</refname>
+ <refpurpose>chiude una connessione PostgreSQL</refpurpose>
+ </refnamediv>
+ <refsect1>
+ <title>Descrizione</title>
+ <funcsynopsis>
+ <funcprototype>
+ <funcdef>bool <function>pg_close</function></funcdef>
+ <paramdef>int <parameter>connection</parameter></paramdef>
+ </funcprototype>
+ </funcsynopsis>
+ <para>
+ Restituisce falso se connection non è un valido indice di connessione, vero
+ altrimenti. Chiude la connessione con il database PostgreSQL associato
+ all'indice di connessione fornito.
+ </para>
+ </refsect1>
+ </refentry>
+
+ <refentry id="function.pg-cmdtuples">
+ <refnamediv>
+ <refname>pg_cmdTuples</refname>
+ <refpurpose>restituisce il numero di tuples interessate</refpurpose>
+ </refnamediv>
+ <refsect1>
+ <title>Descrizione</title>
+ <funcsynopsis>
+ <funcprototype>
+ <funcdef>int <function>pg_cmdtuples</function></funcdef>
+ <paramdef>int <parameter>result_id</parameter></paramdef>
+ </funcprototype>
+ </funcsynopsis>
+ <para>
+ <function>pg_cmdTuples</function> restituisce il numero di tuples
+ (instanze) interessate dalle query INSERT, UPDATE, e DELETE. Se nessuna
+ tuple è interessata la funzione restituirà 0.
+ <example>
+ <title>pg_cmdtuples</title>
+ <programlisting role="php">
+&lt;?php
+$result = pg_exec($conn, "INSERT INTO verlag VALUES ('Autor')");
+$cmdtuples = pg_cmdtuples($result);
+echo $cmdtuples . " &lt;- cmdtuples affected.";
+?>
+ </programlisting>
+ </example>
+ </para>
+ </refsect1>
+ </refentry>
+
+ <refentry id="function.pg-connect">
+ <refnamediv>
+ <refname>pg_Connect</refname>
+ <refpurpose>apre una connessione</refpurpose>
+ </refnamediv>
+ <refsect1>
+ <title>Descrizione</title>
+ <funcsynopsis>
+ <funcprototype>
+ <funcdef>int <function>pg_connect</function></funcdef>
+ <paramdef>string <parameter>host</parameter></paramdef>
+ <paramdef>string <parameter>port</parameter></paramdef>
+ <paramdef>string <parameter>options</parameter></paramdef>
+ <paramdef>string <parameter>tty</parameter></paramdef>
+ <paramdef>string <parameter>dbname</parameter></paramdef>
+ </funcprototype>
+ </funcsynopsis>
+ <para>
+ Restituisce un indice di connessione se la chiamata ha avuto successo, o falso se la connessione
+ non può essere creata. Apre una connessione ad un database PostgreSQL.
+ Tutti i parametri devono essere delle quoted string, incluso il numero della porta.
+ I parametri options e tty sono opzionali e possono essere tralasciati.
+ Questa funzione ritorna un indice di connessione che è richiesto dalle
+ altre funzioni di PostgreSQL. Potete avere multiple connessioni aperte
+ nello stesso momento.
+ </para>
+ <para>
+ Una connessione può essere anche stabilita con il seguente comando:
+ <command>$conn = pg_connect("dbname=marliese port=5432");</command>
+ Gli altri parametri oltre <parameter>dbname</parameter> e
+ <parameter>port</parameter> sono <parameter>host</parameter>,
+ <parameter>tty</parameter>, <parameter>options</parameter>,
+ <parameter>user</parameter> e <parameter>password</parameter>.
+ </para>
+ <para>
+ Vedere anche <function>pg_pConnect</function>.
+ </para>
+ </refsect1>
+ </refentry>
+
+ <refentry id="function.pg-dbname">
+ <refnamediv>
+ <refname>pg_DBname</refname>
+ <refpurpose>nome del database</refpurpose>
+ </refnamediv>
+ <refsect1>
+ <title>Descrizione</title>
+ <funcsynopsis>
+ <funcprototype>
+ <funcdef>string <function>pg_dbname</function></funcdef>
+ <paramdef>int <parameter>connection</parameter></paramdef>
+ </funcprototype>
+ </funcsynopsis>
+ <para>
+ Restituisce il nome del database a cui si riferisce l'indice di connessione
+ PostgreSQL che è stato fornito, o falso se connection non è un valido
+ indice di connessione.
+ </para>
+ </refsect1>
+ </refentry>
+
+ <refentry id="function.pg-errormessage">
+ <refnamediv>
+ <refname>pg_ErrorMessage</refname>
+ <refpurpose>messaggio di errore</refpurpose>
+ </refnamediv>
+ <refsect1>
+ <title>Descrizione</title>
+ <funcsynopsis>
+ <funcprototype>
+ <funcdef>string <function>pg_errormessage</function></funcdef>
+ <paramdef>int <parameter>connection</parameter></paramdef>
+ </funcprototype>
+ </funcsynopsis>
+ <para>
+ Restituisce una stringa contenente il messaggio di errore, falso se fallise.
+ Dettagli riguardo l'errore probabilmente non possono essere ottenuti
+ usando la funzione <function>pg_errormessage</function> se un errore è
+ avvenuto sull'ultima azione sul database per la quale esiste una
+ connessione valida, questa funzione ritornerà una stringa contenente
+ il messaggio di errore generato dal backend server.
+ </para>
+ </refsect1>
+ </refentry>
+
+ <refentry id="function.pg-exec">
+ <refnamediv>
+ <refname>pg_Exec</refname>
+ <refpurpose>esegue una query</refpurpose>
+ </refnamediv>
+ <refsect1>
+ <title>Descrizione</title>
+ <funcsynopsis>
+ <funcprototype>
+ <funcdef>int <function>pg_exec</function></funcdef>
+ <paramdef>int <parameter>connection</parameter></paramdef>
+ <paramdef>string <parameter>query</parameter></paramdef>
+ </funcprototype>
+ </funcsynopsis>
+ <para>
+ Restituisce un indice di result se la query può venire eseguita, falso
+ se fallisce o se connection non è un valido indice di connessione. Dettagli
+ riguardo l'errore possono essere ottenuti usando la funzione
+ <function>pg_ErrorMessage</function> se connection è
+ valido. Invia uno statement SQL al database PostgreSQL specificato dall'indice
+ di connessione. Connection deve essere un indice valido restituito da
+ <function>pg_Connect</function>. Il valore restituito da questa funzione è un indice
+ da usarsi per accedere ai result da altre funzioni PostgreSQL.
+
+ <note>
+ <simpara>
+ PHP/FI restituiva 1 se dalla query non ci si attendeva alcuna restituzione di dati
+ (inserimenti o aggiornamenti, ad esempio) e valori maggiori di 1 anche su selezioni
+ che non ritornavano alcunchè. Nessuna supposizione di questo genere può essere fatta in PHP.
+ </simpara>
+ </note>
+ </para>
+ </refsect1>
+ </refentry>
+
+ <refentry id="function.pg-fetch-array">
+ <refnamediv>
+ <refname>pg_Fetch_Array</refname>
+ <refpurpose>elabora una riga come un vettore</refpurpose>
+ </refnamediv>
+ <refsect1>
+ <title>Descrizione</title>
+ <funcsynopsis>
+ <funcprototype>
+ <funcdef>array <function>pg_fetch_array</function></funcdef>
+ <paramdef>int <parameter>result</parameter></paramdef>
+ <paramdef>int <parameter>row</parameter></paramdef>
+ <paramdef>int
+ <parameter><optional>result_type</optional></parameter>
+ </paramdef>
+ </funcprototype>
+ </funcsynopsis>
+ <para>
+ Restituisce: Un vettore che corrisponde alla riga elaborata, o falso
+ se non ci sono ulteriori righe.</para>
+ <para>
+ <function>pg_fetch_array</function> è una versione estesa di
+ <function>pg_fetch_row</function>. Oltre a salvare i dati
+ negli indici numerici del vettore del result, essa salva anche i dati
+ in indici associativi, usando i nomi dei campi come chiavi.
+ </para>
+ <para>
+ Il terzo parametro opzionale <parameter>result_type</parameter> in
+
+ <function>pg_fetch_array</function> è una costante e può assumere i seguenti
+ valori: PGSQL_ASSOC, PGSQL_NUM, e PGSQL_BOTH.
+ <note>
+ <para>
+ <parameter>Result_type</parameter> è stato aggiunto in PHP 4.0.
+ </para>
+ </note>
+ </para>
+ <para>
+ Un'importante cosa da notare è che l'utilizzo di
+ <function>pg_fetch_array</function> NON è in modo significativo
+ più lento che usare <function>pg_fetch_row</function>, anche se
+ fornisce un significativo valore aggiunto.
+ </para>
+ <para>
+ Per ulteriori dettagli, vedere anche
+ <function>pg_fetch_row</function>
+ </para>
+ <example>
+ <title>elaborazione in un vettore di PostgreSQL</title>
+ <programlisting role="php">
+&lt;?php
+$conn = pg_pconnect("","","","","publisher");
+if (!$conn) {
+ echo "An error occured.\n";
+ exit;
+}
+
+$result = pg_Exec ($conn, "SELECT * FROM authors");
+if (!$result) {
+ echo "An error occured.\n";
+ exit;
+}
+
+$arr = pg_fetch_array ($result, 0);
+echo $arr[0] . " &lt;- array\n";
+
+$arr = pg_fetch_array ($result, 1);
+echo $arr["author"] . " &lt;- array\n";
+?>
+ </programlisting>
+ </example>
+ </refsect1>
+ </refentry>
+
+ <refentry id="function.pg-fetch-object">
+ <refnamediv>
+ <refname>pg_Fetch_Object</refname>
+ <refpurpose>elabora una riga come un oggetto</refpurpose>
+ </refnamediv>
+ <refsect1>
+ <title>Descrizione</title>
+ <funcsynopsis>
+ <funcprototype>
+ <funcdef>object <function>pg_fetch_object</function></funcdef>
+ <paramdef>int <parameter>result</parameter></paramdef>
+ <paramdef>int <parameter>row</parameter></paramdef>
+ <paramdef>int
+ <parameter><optional>result_type</optional></parameter>
+ </paramdef>
+ </funcprototype>
+ </funcsynopsis>
+ <para>
+ Restituisce: Un oggetto con proprietà che corrispondono alla riga elaborata,
+ o falso se non ci sono ulteriori righe.
+ </para>
+ <para>
+ <function>pg_fetch_object</function> è simile a
+ <function>pg_fetch_array</function>, con una differeza - un
+ oggetto viene restituito, invece che un vettore. Indirettamente, ciò
+ significa che potete accedere ai dati solamente tramite i nomi dei campi,
+ e non tramite il loro offset (i numeri sono invalidi nomi di proprietà).
+ </para>
+ <para>
+ Il terzo parametro opzionale <parameter>result_type</parameter> in
+ <function>pg_fetch_object</function> è una costante e può assumere i
+ seguenti valori: PGSQL_ASSOC, PGSQL_NUM, e PGSQL_BOTH.
+ <note>
+ <para>
+ <parameter>Result_type</parameter> è stata aggiunta in PHP 4.0.
+ </para>
+ </note>
+ </para>
+ <para>
+ Per ciò che riguarda la velocità, la funzione è identica a
+ <function>pg_fetch_array</function>, e veloce quasi quanto
+ <function>pg_fetch_row</function> (la differenza è
+ insignificante).
+ </para>
+ <para>
+ Vedere anche: <function>pg_fetch_array</function> e
+ <function>pg_fetch_row</function>.
+ <example>
+ <title>elaborazione in un oggetto di Postgres</title>
+ <programlisting role="php">
+&lt;?php
+$database = "verlag";
+$db_conn = pg_connect ("localhost", "5432", "", "", $database);
+if (!$db_conn): ?>
+ &lt;H1>Failed connecting to postgres database &lt;? echo $database ?>&lt;/H1> &lt;?
+ 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."&lt;BR>";
+ $row++;
+endwhile; ?>
+
+&lt;PRE>&lt;?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++;
+endwhile;
+echo "----------\n"; ?>
+&lt;/PRE> &lt;?php
+pg_freeResult ($qu);
+pg_close ($db_conn);
+?>
+ </programlisting>
+ </example>
+ </para>
+ </refsect1>
+ </refentry>
+
+ <refentry id="function.pg-fetch-row">
+ <refnamediv>
+ <refname>pg_Fetch_Row</refname>
+ <refpurpose>ottiene una riga come un vettore enumerato</refpurpose>
+ </refnamediv>
+ <refsect1>
+ <title>Descrizione</title>
+ <funcsynopsis>
+ <funcprototype>
+ <funcdef>array <function>pg_fetch_row</function></funcdef>
+ <paramdef>int <parameter>result</parameter></paramdef>
+ <paramdef>int <parameter>row</parameter></paramdef>
+ </funcprototype>
+ </funcsynopsis>
+ <para>
+ Restituisce: Un vettore che corrisponde alla riga elaborata, o falso
+ se non ci sono ulteriori righe.
+ </para>
+ <para>
+ <function>pg_fetch_row</function> elabora una riga di dati dal
+ result associato all'identificatore di result specificato. La riga
+ viene restituita come un vettore. Ogni colonna del result viene salvata
+ in un offset del vettore, partendo dall'offset 0.
+ </para>
+ <para>
+ Successive chiamate a <function>pg_fetch_row</function> restituiranno
+ la riga successiva nel set dei result, o falso se non ci sono ulteriori
+ righe.
+ </para>
+ <para>
+ Vedere anche: <function>pg_fetch_array</function>,
+ <function>pg_fetch_object</function>,
+ <function>pg_result</function>.
+ <example>
+ <title>Postgres fetch row</title>
+ <programlisting role="php">
+&lt;?php
+$conn = pg_pconnect("","","","","publisher");
+if (!$conn) {
+ echo "An error occured.\n";
+ exit;
+}
+
+$result = pg_Exec ($conn, "SELECT * FROM authors");
+if (!$result) {
+ echo "An error occured.\n";
+ exit;
+}
+
+$row = pg_fetch_row ($result, 0);
+echo $row[0] . " &lt;- row\n";
+
+$row = pg_fetch_row ($result, 1);
+echo $row[0] . " &lt;- row\n";
+
+$row = pg_fetch_row ($result, 2);
+echo $row[1] . " &lt;- row\n";
+?>
+ </programlisting>
+ </example>
+ </para>
+ </refsect1>
+ </refentry>
+
+ <refentry id="function.pg-fieldisnull">
+ <refnamediv>
+ <refname>pg_FieldIsNull</refname>
+ <refpurpose>Controlla se un campo è NULL</refpurpose>
+ </refnamediv>
+ <refsect1>
+ <title>Descrizione</title>
+ <funcsynopsis>
+ <funcprototype>
+ <funcdef>int <function>pg_fieldisnull</function></funcdef>
+ <paramdef>int <parameter>result_id</parameter></paramdef>
+ <paramdef>int <parameter>row</parameter></paramdef>
+ <paramdef>mixed <parameter>field</parameter></paramdef>
+ </funcprototype>
+ </funcsynopsis>
+ <para>
+ Controlla se un campo è nullo o meno. Restituisce 0 se il campo nella
+ riga data non è NULL. Restituisce 1 se il campo nella riga data è NULL.
+ Il campo può essere specificato con il suo numero o con il suo nome. La
+ numerazione delle righe comincia da 0.
+ </para>
+ </refsect1>
+ </refentry>
+
+ <refentry id="function.pg-fieldname">
+ <refnamediv>
+ <refname>pg_FieldName</refname>
+ <refpurpose>Restituisce il nome di un campo</refpurpose>
+ </refnamediv>
+ <refsect1>
+ <title>Descrizione</title>
+ <funcsynopsis>
+ <funcprototype>
+ <funcdef>string <function>pg_fieldname</function></funcdef>
+ <paramdef>int <parameter>result_id</parameter></paramdef>
+ <paramdef>int <parameter>field_number</parameter></paramdef>
+ </funcprototype>
+ </funcsynopsis>
+ <para>
+ <function>pg_FieldName</function> restituirà il nome del
+ campo occupante il numero di colonna specificato nel result
+ associato all'identificatore di result fornito. La numerazione
+ dei campi comincia da 0.
+ </para>
+ </refsect1>
+ </refentry>
+
+ <refentry id="function.pg-fieldnum">
+ <refnamediv>
+ <refname>pg_FieldNum</refname>
+ <refpurpose>Restituisce il numero di una colonna</refpurpose>
+ </refnamediv>
+ <refsect1>
+ <title>Descrizione</title>
+ <funcsynopsis>
+ <funcprototype>
+ <funcdef>int <function>pg_fieldnum</function></funcdef>
+ <paramdef>int <parameter>result_id</parameter></paramdef>
+ <paramdef>string <parameter>field_name</parameter></paramdef>
+ </funcprototype>
+ </funcsynopsis>
+ <para>
+ <function>pg_FieldNum</function> restituirà il numero dello slot della colonna
+ che corrisponde al nome del campo nel result associato all'identifitore di result fornito.
+ La numerazione dei campi comincia da 0. Questa funzione restituisce -1 in caso di errore.
+ </para>
+ </refsect1>
+ </refentry>
+
+ <refentry id="function.pg-fieldprtlen">
+ <refnamediv>
+ <refname>pg_FieldPrtLen</refname>
+ <refpurpose>Restituisce la lunghezza stampata</refpurpose>
+ </refnamediv>
+ <refsect1>
+ <title>Descrizione</title>
+ <funcsynopsis>
+ <funcprototype>
+ <funcdef>int <function>pg_fieldprtlen</function></funcdef>
+ <paramdef>int <parameter>result_id</parameter></paramdef>
+ <paramdef>int <parameter>row_number</parameter></paramdef>
+ <paramdef>string <parameter>field_name</parameter></paramdef>
+ </funcprototype>
+ </funcsynopsis>
+ <para>
+ <function>pg_FieldPrtLen</function> restituirà l'attuale
+ lunghezza stampata (numero di caratteri) di uno specifico valore in un
+ result di PostgreSQL. La numerazione delle righe comincia da 0. Questa
+ funzione restituisce -1 in caso di errore.
+ </para>
+ </refsect1>
+ </refentry>
+
+ <refentry id="function.pg-fieldsize">
+ <refnamediv>
+ <refname>pg_FieldSize</refname>
+ <refpurpose>
+ Restituisce la capacità interna di memorizzazione del campo specificato
+ </refpurpose>
+ </refnamediv>
+ <refsect1>
+ <title>Descrizione</title>
+ <funcsynopsis>
+ <funcprototype>
+ <funcdef>int <function>pg_fieldsize</function></funcdef>
+ <paramdef>int <parameter>result_id</parameter></paramdef>
+ <paramdef>int <parameter>field_number</parameter></paramdef>
+ </funcprototype>
+ </funcsynopsis>
+ <para>
+ <function>pg_FieldSize</function> restituirà la capacità interna di
+ memorizzazione (in byte) del numero del campo nel result di PostgreSQL fornito.
+ La numerazione dei campi comincia da 0. Una dimensione del campo di -1
+ indica un campo a dimensione variabile. Questa funzione restituirà falso
+ in caso di errore.
+ </para>
+ </refsect1>
+ </refentry>
+
+ <refentry id="function.pg-fieldtype">
+ <refnamediv>
+ <refname>pg_FieldType</refname>
+ <refpurpose>
+ Restituisce il nome del tipo per il corrispondente numero del campo
+ </refpurpose>
+ </refnamediv>
+ <refsect1>
+ <title>Descrizione</title>
+ <funcsynopsis>
+ <funcprototype>
+ <funcdef>int <function>pg_fieldtype</function></funcdef>
+ <paramdef>int <parameter>result_id</parameter></paramdef>
+ <paramdef>int <parameter>field_number</parameter></paramdef>
+ </funcprototype>
+ </funcsynopsis>
+ <para>
+ <function>pg_FieldType</function> restituirà una stringa contenente
+ il nome del tipo del campo nel result di PostgreSQL fornito.
+ La numerazione dei campi comincia da 0.
+ </para>
+ </refsect1>
+ </refentry>
+
+ <refentry id="function.pg-freeresult">
+ <refnamediv>
+ <refname>pg_FreeResult</refname>
+ <refpurpose>Libera la memoria</refpurpose>
+ </refnamediv>
+ <refsect1>
+ <title>Descrizione</title>
+ <funcsynopsis>
+ <funcprototype>
+ <funcdef>int <function>pg_freeresult</function></funcdef>
+ <paramdef>int <parameter>result_id</parameter></paramdef>
+ </funcprototype>
+ </funcsynopsis>
+ <para>
+ <function>pg_FreeResult</function> necessita solo di venire chiamata se
+ siete preoccupati di stare usando troppa memoria mentre il vostro script
+ è in esecuzione. Tutta la memoria dei result verrà automaticamente liberata
+ quando lo script termina. Ma, se siete sicuri che i dati nel result non vi
+ serviranno più, potete chiamare la <function>pg_FreeResult</function> con
+ l'identificatore del result come parametro e la memoria associata al result
+ verrà liberata.
+ </para>
+ </refsect1>
+ </refentry>
+
+ <refentry id="function.pg-getlastoid">
+ <refnamediv>
+ <refname>pg_GetLastOid</refname>
+ <refpurpose>Restituisce l'identificare dell'ultimo oggetto</refpurpose>
+ </refnamediv>
+ <refsect1>
+ <title>Descrizione</title>
+ <funcsynopsis>
+ <funcprototype>
+ <funcdef>int <function>pg_getlastoid</function></funcdef>
+ <paramdef>int <parameter>result_id</parameter></paramdef>
+ </funcprototype>
+ </funcsynopsis>
+ <para>
+ <function>pg_GetLastOid</function> può venire usata per ottenere
+ l'Oid assegnato ad un tuple inserito se l'identificatore del result
+ è usato dall'ultimo comando inviato via <function>pg_Exec</function>
+ ed esso era una SQL INSERT. Questa funzione restituirà un intero positivo
+ se c'era un valido Oid. Restituirà -1 se è avvenuto un errore
+ o se l'ultimo comando inviato via <function>pg_Exec</function>
+ non era un INSERT.
+ </para>
+ </refsect1>
+ </refentry>
+
+ <refentry id="function.pg-host">
+ <refnamediv>
+ <refname>pg_Host</refname>
+ <refpurpose>Restituisce il nome dell'host</refpurpose>
+ </refnamediv>
+ <refsect1>
+ <title>Descrizione</title>
+ <funcsynopsis>
+ <funcprototype>
+ <funcdef>string <function>pg_host</function></funcdef>
+ <paramdef>int <parameter>connection_id</parameter></paramdef>
+ </funcprototype>
+ </funcsynopsis>
+ <para>
+ <function>pg_Host</function> restituirà il nome
+ dell'host a cui è connesso lo specificato identificatore di connessione di PostgreSQL.
+ </para>
+ </refsect1>
+ </refentry>
+
+ <refentry id="function.pg-loclose">
+ <refnamediv>
+ <refname>pg_loclose</refname>
+ <refpurpose>chiude un large object</refpurpose>
+ </refnamediv>
+ <refsect1>
+ <title>Descrizione</title>
+ <funcsynopsis>
+ <funcprototype>
+ <funcdef>void <function>pg_loclose</function></funcdef>
+ <paramdef>int <parameter>fd</parameter></paramdef>
+ </funcprototype>
+ </funcsynopsis>
+ <para>
+ <function>pg_loclose</function> chiude un Inversion Large
+ Object. <parameter>fd</parameter> è un descrittore di file per il
+ large object preso da <function>pg_loopen</function>.
+ </para>
+ </refsect1>
+ </refentry>
+
+ <refentry id="function.pg-locreate">
+ <refnamediv>
+ <refname>pg_locreate</refname>
+ <refpurpose>crea un large object</refpurpose>
+ </refnamediv>
+ <refsect1>
+ <title>Descrizione</title>
+ <funcsynopsis>
+ <funcprototype>
+ <funcdef>int <function>pg_locreate</function></funcdef>
+ <paramdef>int <parameter>conn</parameter></paramdef>
+ </funcprototype>
+ </funcsynopsis>
+ <para>
+ <function>pg_locreate</function> crea un Inversion Large
+ Object e restituisce l'oid del large object.
+ <parameter>conn</parameter> specifica una valida connessione al
+ database. Le modalità di accesso di PostgreSQL INV_READ, INV_WRITE, e
+ INV_ARCHIVE non sono supportate, l'oggetto viene creato sempre con
+ accesso sia in lettura che in scrittura. INV_ARCHIVE è stato rimosso
+ anche dallo stesso PostgreSQL (versione 6.3 e successive)
+ </para>
+ </refsect1>
+ </refentry>
+
+ <refentry id="function.pg-loexport">
+ <refnamediv>
+ <refname>pg_loexport</refname>
+ <refpurpose>esporta un large object su un file</refpurpose>
+ </refnamediv>
+ <refsect1>
+ <title>Descrizione</title>
+ <funcsynopsis>
+ <funcprototype>
+ <funcdef>bool <function>pg_loexport</function></funcdef>
+ <paramdef>int
+ <parameter>oid</parameter>