mirror of
https://github.com/php/doc-de.git
synced 2026-03-29 01:32:07 +01:00
git-svn-id: https://svn.php.net/repository/phpdoc/de/trunk@185599 c90b9560-bf6c-de11-be94-00142212c4b1
357 lines
12 KiB
XML
357 lines
12 KiB
XML
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!-- $Revision: 1.9 $ -->
|
|
<!-- EN-Revision: 1.25 Maintainer: conni Status: ready -->
|
|
<reference id='ref.pgsql'>
|
|
<title>PostgreSQL Funktionen</title>
|
|
<titleabbrev>PostgreSQL</titleabbrev>
|
|
|
|
<partintro>
|
|
<section id="pgsql.intro">
|
|
&reftitle.intro;
|
|
<para>
|
|
PostgreSQL ist ein kostenloses Open Source Datenbanksystem. Es
|
|
wurde ursprünglich im UC Berkeley Computer Science
|
|
Department entwickelt und hat Pionierarbeit bei objektrelationalen
|
|
Datenbankkonzepten geleistet, die jetzt Einzug in einige
|
|
kommerzielle Datenbanken halten. PostgreSQL bietet SQL92/SQL99
|
|
Sprachunterstützung, Transaktionen, referentielle Integrität,
|
|
benutzerdefinierte Funktionen und ein erweiterbares Typkonzept.
|
|
PostgreSQL ist eine Weiterentwicklung des ursprünglichen Berkeley-Codes.
|
|
</para>
|
|
</section>
|
|
|
|
<section id="pgsql.requirements">
|
|
&reftitle.required;
|
|
<para>
|
|
Um PostgreSQL benutzen zu können, brauchen Sie mindestens eine
|
|
Version 6.5 oder später. Um alle Leistungsmerkmale des
|
|
PostgreSQL-Moduls nutzen zu können, müssen Sie eine Version ab
|
|
8.0 haben. PostgreSQL unterstützt viele Zeichencodierungen,
|
|
einschließlich multibyte character encoding. Die aktuelle Version
|
|
sowie weitere Informationen über PostgreSQL sind auf den Seiten
|
|
<ulink url="&url.pgsql;">&url.pgsql;</ulink> erhältlich und die
|
|
ausführliche Dokumentation finden Sie unter
|
|
<ulink url="&url.pgsql;">&url.pgsql.techdocs;</ulink>.
|
|
</para>
|
|
</section>
|
|
|
|
&reference.pgsql.configure;
|
|
|
|
&reference.pgsql.ini;
|
|
|
|
<section id="pgsql.using">
|
|
<title>Hinweise</title>
|
|
<warning>
|
|
<para>
|
|
Wegen eines Bugs in der Behandlung von NOTICE-Benachrichtigungen
|
|
sollte das PostgreSQL-Modul der PHP Version 4.0.6 nicht
|
|
benutzt werden. Bitte benutzen Sie PHP 4.1.0 oder höher.
|
|
</para>
|
|
</warning>
|
|
<warning>
|
|
<para>
|
|
Die Namen der PostgreSQL-Funktionen wurden ab der PHP Version
|
|
4.2.0 geändert, um sie an die gültigen Coding-Standards anzupassen.
|
|
Die meisten neuen Namen enthalten zusätzliche Unterstriche, z.B.
|
|
pg_lo_open(). Einige Funktionen wurden der Einheitlichkeit wegen
|
|
umbenannt, z.B. pg_exec() zu pg_query(). Die älteren Namen können
|
|
in der Version 4.2.0 und auch ein paar Releases danach noch
|
|
verwendet werden, aber sie werden irgendwann gelöscht.
|
|
</para>
|
|
<table>
|
|
<title>Die geänderten Funktionsnamen</title>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>Alter Name</entry>
|
|
<entry>Neuer Name</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry><function>pg_cmdtuples</function></entry>
|
|
<entry><function>pg_affected_rows</function></entry>
|
|
</row>
|
|
<row>
|
|
<entry><function>pg_errormessage</function></entry>
|
|
<entry><function>pg_last_error</function></entry>
|
|
</row>
|
|
<row>
|
|
<entry><function>pg_exec</function></entry>
|
|
<entry><function>pg_query</function></entry>
|
|
</row>
|
|
<row>
|
|
<entry><function>pg_fieldname</function></entry>
|
|
<entry><function>pg_field_name</function></entry>
|
|
</row>
|
|
<row>
|
|
<entry><function>pg_fieldsize</function></entry>
|
|
<entry><function>pg_field_size</function></entry>
|
|
</row>
|
|
<row>
|
|
<entry><function>pg_fieldnum</function></entry>
|
|
<entry><function>pg_field_num</function></entry>
|
|
</row>
|
|
<row>
|
|
<entry><function>pg_fieldprtlen</function></entry>
|
|
<entry><function>pg_field_prtlen</function></entry>
|
|
</row>
|
|
<row>
|
|
<entry><function>pg_fieldisnull</function></entry>
|
|
<entry><function>pg_field_is_null</function></entry>
|
|
</row>
|
|
<row>
|
|
<entry><function>pg_freeresult</function></entry>
|
|
<entry><function>pg_free_result</function></entry>
|
|
</row>
|
|
<row>
|
|
<entry><function>pg_getlastoid</function></entry>
|
|
<entry><function>pg_last_oid</function></entry>
|
|
</row>
|
|
<row>
|
|
<entry><function>pg_loreadall</function></entry>
|
|
<entry><function>pg_lo_read_all</function></entry>
|
|
</row>
|
|
<row>
|
|
<entry><function>pg_locreate</function></entry>
|
|
<entry><function>pg_lo_create</function></entry>
|
|
</row>
|
|
<row>
|
|
<entry><function>pg_lounlink</function></entry>
|
|
<entry><function>pg_lo_unlink</function></entry>
|
|
</row>
|
|
<row>
|
|
<entry><function>pg_loopen</function></entry>
|
|
<entry><function>pg_lo_open</function></entry>
|
|
</row>
|
|
<row>
|
|
<entry><function>pg_loclose</function></entry>
|
|
<entry><function>pg_lo_close</function></entry>
|
|
</row>
|
|
<row>
|
|
<entry><function>pg_loread</function></entry>
|
|
<entry><function>pg_lo_read</function></entry>
|
|
</row>
|
|
<row>
|
|
<entry><function>pg_lowrite</function></entry>
|
|
<entry><function>pg_lo_write</function></entry>
|
|
</row>
|
|
<row>
|
|
<entry><function>pg_loimport</function></entry>
|
|
<entry><function>pg_lo_import</function></entry>
|
|
</row>
|
|
<row>
|
|
<entry><function>pg_loexport</function></entry>
|
|
<entry><function>pg_lo_export</function></entry>
|
|
</row>
|
|
<row>
|
|
<entry><function>pg_numrows</function></entry>
|
|
<entry><function>pg_num_rows</function></entry>
|
|
</row>
|
|
<row>
|
|
<entry><function>pg_numfields</function></entry>
|
|
<entry><function>pg_num_fields</function></entry>
|
|
</row>
|
|
<row>
|
|
<entry><function>pg_result</function></entry>
|
|
<entry><function>pg_fetch_result</function></entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</table>
|
|
<para>
|
|
Die veraltete Syntax von <function>pg_connect</function> und
|
|
<function>pg_pconnect</function> wird ungültig
|
|
werden, um zukünftig asynchrone Verbindungen zu unterstützen.
|
|
Bitte benutzen Sie einen Verbindungsstring mit
|
|
<function>pg_connect</function> bzw. <function>pg_pconnect</function>.
|
|
</para>
|
|
</warning>
|
|
<para>
|
|
Nicht alle Funktionen sind in allen Versionen verfügbar. Es hängt
|
|
davon ab, welche libpq Version (das PostgreSQL C Client Interface)
|
|
auf Ihrem Rechner verfügbar ist und wie libpq kompiliert wurde.
|
|
Falls eine Funktion nicht verfügbar ist, liegt es daran, dass libpq
|
|
die nötigen Routinen nicht unterstützt, die die Funktion braucht.
|
|
</para>
|
|
<para>
|
|
Es ist außerdem wichtig, dass Ihre libpq nicht älter ist, als der
|
|
PostgreSQL-Server, zu dem Sie eine Verbindung aufbauen. Wenn Sie
|
|
eine libpq benutzen, die älter ist, als vom PostgreSQL-Server
|
|
erwartet, werden Sie wahrscheinlich Probleme haben.
|
|
</para>
|
|
<para>
|
|
Seit Version 6.3 (03/02/1998) benutzt PostgreSQL per Voreinstellung
|
|
Unix Domain Sockets. Ein TCP/IP Port wird NICHT standardmäßig
|
|
geöffnet. In der untenstehenden Tabelle werden diese neuen
|
|
Verbindungsmöglichkeiten gezeigt. Der Socket ist in
|
|
<filename>/tmp/.s.PGSQL.5432</filename> zu finden. Der Schalter
|
|
-i, der dem <command>postmaster</command> mitgegeben werden kann,
|
|
weist diesen an, sowohl über TCP/IP Sockets als auch über UNIX Domain
|
|
Sockets eine Verbindung aufzubauen.
|
|
<table>
|
|
<title>Der Postmaster und 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=MyDbName");</entry>
|
|
<entry>OK</entry>
|
|
</row>
|
|
<row>
|
|
<entry>postmaster -i &</entry>
|
|
<entry>pg_connect("dbname=MyDbName");</entry>
|
|
<entry>OK</entry>
|
|
</row>
|
|
<row>
|
|
<entry>postmaster &</entry>
|
|
<entry>pg_connect("host=localhost dbname=MyDbName");</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
|
|
/pfad/zu/datei.php on line 20.
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>postmaster -i &</entry>
|
|
<entry>pg_connect("host=localhost dbname=MyDbName");</entry>
|
|
<entry>OK</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</table>
|
|
</para>
|
|
<para>
|
|
Eine Verbindung zu einem PostgreSQL-Server lässt sich auch mit den
|
|
folgenden Wertepaaren, die im Verbindungsstring gesetzt werden,
|
|
herstellen (wobei mindestens der Name der Datenbank
|
|
angegeben sein muss): <command>$conn =
|
|
pg_connect("host=myHost port=myPort tty=myTTY options=myOptions
|
|
dbname=myDB user=myUser password=myPassword ");
|
|
</command>
|
|
</para>
|
|
<para>
|
|
Die bisherige Syntax
|
|
<command>
|
|
$conn = pg_connect ("host", "port", "options", "tty", "dbname")
|
|
</command>
|
|
ist veraltet und sollte nicht weiter verwendet werden.
|
|
</para>
|
|
<para>
|
|
Umgebungsvariablen beeinflussen das Server/Client-Verhalten von
|
|
PostgreSQL. Zum Beispiel sucht das PostgreSQL-Modul nach der
|
|
Umgebungsvariablen PGHOST, falls der Hostname im Verbindungsstring
|
|
nicht angegeben wurde. Die unterstützten Umgebungsvariablen
|
|
variieren von Version zu Version. Schauen Sie für weitere
|
|
Informationen in den PostgreSQL Programmer's Guide (nach den libpq
|
|
Umgebungsvariablen).
|
|
</para>
|
|
<para>
|
|
Versichen Sie sich, dass Sie die Umgebungsvariable für den
|
|
aktuellen Benutzer gesetzt haben. Um sich die Umgebungsvariablen,
|
|
die für den aktuellen Prozess verfügbar sind, anzeigen zu lassen,
|
|
benutzen Sie <literal>$_ENV</literal> oder
|
|
<function>getenv</function>.
|
|
</para>
|
|
<example>
|
|
<title>Umgebungsvariablen setzen</title>
|
|
<programlisting role='php'>
|
|
<![CDATA[
|
|
PGHOST=psgql.exmaple.com
|
|
PGPORT=7890
|
|
PGDATABASE=web-system
|
|
PGUSER=web-user
|
|
PGPASSWORD=secret
|
|
PGDATESTYLE=ISO
|
|
PGTZ=JST
|
|
PGCLIENTENCODING=EUC-JP
|
|
|
|
export PGHOST PGPORT PGDATABASE PGUSER PGPASSWORD PGDATESTYLE PGTZ PGCLIENTENCODING
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
<note>
|
|
<para>
|
|
PostgreSQL konvertiert alle Bezeichner automatisch in
|
|
Kleinbuschstaben (z. B. Tabellen. oder Spaltennamen). Wenn Sie
|
|
Großbuchstaben benutzen wollen. müssen Sie die Namen in
|
|
Anführungszeichen schreiben.
|
|
</para>
|
|
</note>
|
|
</section>
|
|
|
|
&reference.pgsql.constants;
|
|
|
|
<section id="pgsql.examples">
|
|
&reftitle.examples;
|
|
|
|
<para>
|
|
Ab der PostgreSQL Version 7.1.0 ist die maximale Grösse eines Feldes
|
|
mit dem Datentyp text 1GB. Ältere PostgreSQL Versionen begrenzten
|
|
Felder vom Typ text auf Blockgrösse (normalerweise 8 KB bis maximal
|
|
32 KB, falls dies bei der Kompilation angegeben wurde).
|
|
</para>
|
|
<para>
|
|
Um die Large Object-Schnittstelle (lo) zu benutzen, ist es nötig,
|
|
die Large-Object-Funktionen in einen Transaktionsblock einzuschließen.
|
|
Ein Transaktionsblock beginnt mit einem SQL-Befehl
|
|
<command>BEGIN</command> und endet, falls die Transaktion gültig
|
|
war, mit <command>COMMIT</command> oder <command>END</command>.
|
|
Wenn die Transaktion fehlschlägt, sollte sie mit
|
|
<command>ROLLBACK</command> oder <command>ABORT</command>
|
|
geschlossen werden.
|
|
<example>
|
|
<title>Large Objects benutzen</title>
|
|
<programlisting role='php'>
|
|
<![CDATA[
|
|
<?php
|
|
$database = pg_connect ("dbname=jacarta");
|
|
pg_query ($database, "begin");
|
|
$oid = pg_lo_create ($database);
|
|
echo ("$oid\n");
|
|
$handle = pg_lo_open ($database, $oid, "w");
|
|
echo ("$handle\n");
|
|
pg_lo_write ($handle, "Daten des Large Objects");
|
|
pg_lo_close ($handle);
|
|
pg_query ($database, "commit");
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
Schließen Sie zuerst das Large Object, bevor Sie die Verbindung zum PostgreSQL Server schließen.
|
|
</para>
|
|
</section>
|
|
</partintro>
|
|
|
|
&reference.pgsql.functions;
|
|
|
|
</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
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"../../../manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|