Hallo Catharina, jetzt sieht es etwas besser aus wie bei Hempels unterm Sofa.

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@18013 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Egon Schmid 1999-12-27 20:42:55 +00:00
parent b0bc1fa835
commit 5ab6228995

View file

@ -3,17 +3,18 @@
<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>
descendant of this original Berkeley code.
</para>
<para>
PostgreSQL is available without cost. The current version is
available at <ulink url="http://www.postgresql.org/">www.PostgreSQL.org</ulink>.</para>
available at <ulink url="&url.pgsql;">www.PostgreSQL.org</ulink>.
</para>
<para>
Since version 6.3 (03/02/1998) PostgreSQL use unix domain sockets,
a table is given to this new possibilities. This socket will be
@ -21,45 +22,51 @@
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
socket".
<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 &</entry>
<entry>pg_connect("", "", "", "", "dbname");</entry>
<entry>OK</entry>
</row>
<row>
<entry>postmaster -i &</entry>
<entry>pg_connect("", "", "", "", "dbname");</entry>
<entry>OK</entry>
</row>
<row>
<entry>postmaster &</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 &</entry>
<entry>pg_connect("localhost", "", "", "", "dbname");</entry>
<entry>OK</entry>
</row>
</tbody>
</tgroup>
</table></para>
<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 &</entry>
<entry>pg_connect("", "", "", "", "dbname");</entry>
<entry>OK</entry>
</row>
<row>
<entry>postmaster -i &</entry>
<entry>pg_connect("", "", "", "", "dbname");</entry>
<entry>OK</entry>
</row>
<row>
<entry>postmaster &</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 &</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>
<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
@ -83,10 +90,9 @@ pg_exec ($database, "begin");
pg_exec ($database, "commit")
pg_exec ($database, "end")
?>
</programlisting>
</example></para>
</programlisting>
</example>
</para>
</partintro>
<refentry id="function.pg-close">
@ -103,11 +109,11 @@ pg_exec ($database, "end")
<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>
associated with the given connection index.
</para>
</refsect1>
</refentry>
<refentry id="function.pg-cmdtuples">
<refnamediv>
<refname>pg_cmdTuples</refname>
@ -120,21 +126,20 @@ pg_exec ($database, "end")
<paramdef>int <parameter>result_id</parameter></paramdef>
</funcsynopsis>
<para>
pg_cmdTuples() 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">
<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 . " <- cmdtuples affected.";
?>
</programlisting>
</example></para>
</programlisting>
</example>
</para>
</refsect1>
</refentry>
@ -160,16 +165,19 @@ echo $cmdtuples . " <- cmdtuples affected.";
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>
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>
<parameter>user</parameter> and <parameter>password</parameter>.
</para>
<para>
See also <function>pg_pConnect</function>.</para>
See also <function>pg_pConnect</function>.
</para>
</refsect1>
</refentry>
@ -187,7 +195,8 @@ echo $cmdtuples . " <- cmdtuples affected.";
<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>
valid connection index.
</para>
</refsect1>
</refentry>
@ -205,10 +214,11 @@ echo $cmdtuples . " <- cmdtuples affected.";
<para>
Returns a string containing the error message, false on failure.
Details about the error probably cannot be retrieved using the
pg_errormessage() function if an error occured
<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>
generated by the backend server.
</para>
</refsect1>
</refentry>
@ -234,12 +244,15 @@ echo $cmdtuples . " <- cmdtuples affected.";
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>
<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>
@ -265,20 +278,24 @@ echo $cmdtuples . " <- cmdtuples affected.";
<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>
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>
<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>
provides a significant added value.
</para>
<para>
For further details, also see
<function>pg_fetch_row</function>
@ -305,9 +322,8 @@ echo $arr[0] . " <- array\n";
$arr = pg_fetch_array ($result, 1);
echo $arr["author"] . " <- array\n";
?>
</programlisting>
</programlisting>
</example>
</refsect1>
</refentry>
@ -328,32 +344,37 @@ echo $arr["author"] . " <- array\n";
</funcsynopsis>
<para>
Returns: An object with properties that correspond to the fetched
row, or false if there are no more rows.</para>
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>
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>
<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">
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);
@ -391,9 +412,9 @@ echo "----------\n"; ?>
pg_freeResult ($qu);
pg_close ($db_conn);
?>
</programlisting>
</example></para>
</programlisting>
</example>
</para>
</refsect1>
</refentry>
@ -411,24 +432,26 @@ pg_close ($db_conn);
</funcsynopsis>
<para>
Returns: An array that corresponds to the fetched row, or false
if there are no more rows.</para>
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>
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>
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">
<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) {
@ -451,9 +474,9 @@ echo $row[0] . " <- row\n";
$row = pg_fetch_row ($result, 2);
echo $row[1] . " <- row\n";
?>
</programlisting>
</example></para>
</programlisting>
</example>
</para>
</refsect1>
</refentry>
@ -474,7 +497,8 @@ echo $row[1] . " <- row\n";
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>
numbering starts at 0.
</para>
</refsect1>
</refentry>
@ -491,9 +515,10 @@ echo $row[1] . " <- row\n";
<paramdef>int <parameter>field_number</parameter></paramdef>
</funcsynopsis>
<para>
pg_FieldName() will return the name of the field occupying the
given column number in the given PostgreSQL result identifier.
Field numbering starts from 0.</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>
@ -510,10 +535,11 @@ echo $row[1] . " <- row\n";
<paramdef>string <parameter>field_name</parameter></paramdef>
</funcsynopsis>
<para>
pg_FieldNum() 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>
<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>
@ -531,16 +557,20 @@ echo $row[1] . " <- row\n";
<paramdef>string <parameter>field_name</parameter></paramdef>
</funcsynopsis>
<para>
pg_FieldPrtLen() 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>
<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>
<refname>pg_FieldSize</refname>
<refpurpose>
Returns the internal storage size of the named field
</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
@ -554,14 +584,16 @@ echo $row[1] . " <- row\n";
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>
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>
Returns the type name for the corresponding field number
</refpurpose>
</refnamediv>
<refsect1>
@ -572,9 +604,10 @@ echo $row[1] . " <- row\n";
<paramdef>int <parameter>field_number</parameter></paramdef>
</funcsynopsis>
<para>
pg_FieldType() will return a string containing the type name of
the given field in the given PostgreSQL result identifier. Field
numbering starts at 0.</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>
@ -596,7 +629,8 @@ echo $row[1] . " <- row\n";
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>
an argument and the associated result memory will be freed.
</para>
</refsect1>
</refentry>
@ -618,7 +652,8 @@ echo $row[1] . " <- row\n";
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>
was not an INSERT.
</para>
</refsect1>
</refentry>
@ -634,8 +669,9 @@ echo $row[1] . " <- row\n";
<paramdef>int <parameter>connection_id</parameter></paramdef>
</funcsynopsis>
<para>
pg_Host() will return the host name of the given PostgreSQL
connection identifier is connected to.</para>
<function>pg_Host</function> will return the host name of the
given PostgreSQL connection identifier is connected to.
</para>
</refsect1>
</refentry>
@ -652,8 +688,9 @@ echo $row[1] . " <- row\n";
</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>
Object. <parameter>fd</parameter> is a file descriptor for the
large object from <function>pg_loopen</function>.
</para>
</refsect1>
</refentry>
@ -671,11 +708,12 @@ echo $row[1] . " <- row\n";
<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>
<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>
@ -698,7 +736,8 @@ echo $row[1] . " <- row\n";
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>
and <parameter>mode</parameter> can be either "r", "w", or "rw".
</para>
</refsect1>
</refentry>
@ -720,11 +759,12 @@ echo $row[1] . " <- row\n";
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>
allowable size of the large object segment.
</para>
</refsect1>
</refentry>
<refentry id="function.pg-loreadall">
<refentry id="function.pg-loreadall">
<refnamediv>
<refname>pg_loreadall</refname>
<refpurpose>read a entire large object</refpurpose>
@ -738,11 +778,12 @@ echo $row[1] . " <- row\n";
<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>
headers. Mainly intended for sending binary data like images or sound.
</para>
</refsect1>
</refentry>
<refentry id="function.pg-lounlink">
<refentry id="function.pg-lounlink">
<refnamediv>
<refname>pg_lounlink</refname>
<refpurpose>delete a large object</refpurpose>
@ -756,11 +797,12 @@ echo $row[1] . " <- row\n";
</funcsynopsis>
<para>
<function>pg_lounlink</function> deletes a large object with the
<parameter>lobjid</parameter> identifier for that large object.</para>
<parameter>lobjid</parameter> identifier for that large object.
</para>
</refsect1>
</refentry>
<refentry id="function.pg-lowrite">
<refentry id="function.pg-lowrite">
<refnamediv>
<refname>pg_lowrite</refname>
<refpurpose>write a large object</refpurpose>
@ -777,7 +819,8 @@ echo $row[1] . " <- row\n";
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>
object from <function>pg_loopen</function>.
</para>
</refsect1>
</refentry>
@ -793,10 +836,11 @@ echo $row[1] . " <- row\n";
<paramdef>int <parameter>result_id</parameter></paramdef>
</funcsynopsis>
<para>
pg_NumFields() 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>
<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>
@ -815,7 +859,8 @@ echo $row[1] . " <- row\n";
<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>
return -1 on error.
</para>
</refsect1>
</refentry>
@ -831,15 +876,19 @@ echo $row[1] . " <- row\n";
<paramdef>int <parameter>connection_id</parameter></paramdef>
</funcsynopsis>
<para>
pg_Options() will return a string containing the options
specified on the given PostgreSQL connection identifier.</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>
<refpurpose>
Make a persistent database connection
</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
@ -859,15 +908,16 @@ echo $row[1] . " <- row\n";
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>
<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>
<parameter>user</parameter> and <parameter>password</parameter>.
</para>
</refsect1>
</refentry>
@ -883,8 +933,9 @@ echo $row[1] . " <- row\n";
<paramdef>int <parameter>connection_id</parameter></paramdef>
</funcsynopsis>
<para>
pg_Port() will return the port number that the given PostgreSQL
connection identifier is connected to.</para>
<function>pg_Port</function> will return the port number that the
given PostgreSQL connection identifier is connected to.
</para>
</refsect1>
</refentry>
@ -902,13 +953,14 @@ echo $row[1] . " <- row\n";
<paramdef>mixed <parameter>fieldname</parameter></paramdef>
</funcsynopsis>
<para>
pg_Result() will return values from a result identifier produced
by <function>pg_Exec</function>. The
<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>
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
@ -916,7 +968,8 @@ echo $row[1] . " <- row\n";
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>
<command>psql</command> program.
</para>
</refsect1>
</refentry>
@ -932,8 +985,10 @@ echo $row[1] . " <- row\n";
<paramdef>int <parameter>connection_id</parameter></paramdef>
</funcsynopsis>
<para>
pg_tty() will return the tty name that server side debugging
output is sent to on the given PostgreSQL connection identifier.</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>
@ -949,7 +1004,7 @@ sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
sgml-parent-document:nil
sgml-default-dtd-file:"../manual.ced"
sgml-default-dtd-file:"../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil