mirror of
https://github.com/php/doc-it.git
synced 2026-03-27 17:12:15 +01:00
git-svn-id: https://svn.php.net/repository/phpdoc/it/trunk@110942 c90b9560-bf6c-de11-be94-00142212c4b1
328 lines
11 KiB
XML
328 lines
11 KiB
XML
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!-- EN-Revision: 1.12 Maintainer: cucinato Status: working -->
|
|
<!-- CREDITS: fabio,cortesi,denny -->
|
|
<reference id="ref.pgsql">
|
|
<title>Funzioni PostgreSQL</title>
|
|
<titleabbrev>PostgreSQL</titleabbrev>
|
|
|
|
<partintro>
|
|
<section id="pgsql.intro">
|
|
&reftitle.intro;
|
|
<para>
|
|
Il database PostgreSQL è un prodotto OpenSource ed è disponibile gratuitamente.
|
|
Postgres, sviluppato originariamente nel Dipartimento di Informatica dell'Università di
|
|
Berkeley, ha anticipato molti dei concetti su oggetti e relazioni che ora
|
|
stanno diventando disponibili in alcuni database commerciali. Postgres fornisce
|
|
supporto per il linguaggio SQL/92/SQL99, integrità transazionale ed estensibilità
|
|
dei tipi. PostgreSQL è un discendente open source dell'originario
|
|
codice di Berkeley.
|
|
</para>
|
|
</section>
|
|
|
|
<section id="pgsql.requirements">
|
|
&reftitle.required;
|
|
<para>
|
|
Per utilizzare il supporto a PostgreSQL, occorre PostgreSQL 6.5 o
|
|
versioni più recenti. PostgreSQL 7.0 o successivi permettono di abilitare tutte le funzionalità
|
|
di questo modulo. PostgreSQL ammette molte codifiche di carattere, tra cui
|
|
la codifica multibyte. La versione corrente e maggiori
|
|
informazioni su PostgreSQL sono disponibili su <ulink
|
|
url="&url.pgsql;">&url.pgsql;</ulink>.
|
|
</para>
|
|
</section>
|
|
|
|
&reference.pgsql.configure;
|
|
|
|
&reference.pgsql.ini;
|
|
|
|
<section id="pgsql.using">
|
|
<title>Utilizzo e suggerimenti</title>
|
|
<warning>
|
|
<para>
|
|
L'utilizzo del modulo PostgreSQL con PHP 4.0.6 non è raccomandato a causa
|
|
di un bug nella gestione dei messaggi. Si usi PHP 4.1.0 o successivi.
|
|
</para>
|
|
</warning>
|
|
<warning>
|
|
<para>
|
|
I nomi delle funzioni relative a PostgreSQL verranno cambiate a partire dalla versione 4.2.0 per
|
|
conformarsi agli standard di sviluppo attuali. La maggior parte dei nuovi nomi avrà
|
|
underscore aggiuntivi, per esempio pg_lo_open(). Alcune funzioni verranno rinominate
|
|
per dare consistenza. Per esempio pg_exec() diventerà
|
|
pg_query(). I vecchi nomi potranno essere usati nella versione 4.2.0 e in alcune versioni
|
|
successive alla 4.2.0, ma potranno essere cancellati in futuro.
|
|
</para>
|
|
<table>
|
|
<title>Nomi di funzione cambiati</title>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>Vecchio nome</entry>
|
|
<entry>Nuovo nome</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry><function>pg_exec</function></entry>
|
|
<entry><function>pg_query</function></entry>
|
|
</row>
|
|
<row>
|
|
<entry><function>pg_getlastoid</function></entry>
|
|
<entry><function>pg_last_oid</function></entry>
|
|
</row>
|
|
<row>
|
|
<entry><function>pg_cmdtuples</function></entry>
|
|
<entry><function>pg_affected_rows</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_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_result</function></entry>
|
|
<entry><function>pg_fetch_result</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>
|
|
</tbody>
|
|
</tgroup>
|
|
</table>
|
|
<para>
|
|
La vecchia sintassi di <function>pg_connect</function>/<function>pg_pconnect</function>
|
|
sarà deprecata per supportare, in futuro, connessioni asincrone.
|
|
Si usi una stringa di connessione con <function>pg_connect</function> e
|
|
<function>pg_pconnect</function>.
|
|
</para>
|
|
</warning>
|
|
<para>
|
|
Non tutte le funzioni sono supportate su tutte le architetture. Dipende dalla versione
|
|
di libpq (L'interfaccia Client C per PostgreSQL) e da come libpq è
|
|
compilato. Se c'è una funzione mancante, libpq non supporta
|
|
la feature richiesta per quella funzione.
|
|
</para>
|
|
<para>
|
|
È importante usare versioni di libpq più recenti rispetto al Server
|
|
PostgreSQL al quale ci si vuole collegare. Se si usa una versione di libpq più vecchia rispetto
|
|
al Server PostgreSQL al quale ci si vuole collegare, si andrà probabilmente incontro a problemi.
|
|
</para>
|
|
<para>
|
|
Fin dalla versione 6.3 (03/02/1998) PostgreSQL usa gli unix domain socket
|
|
di default. La porta TCP, di default, NON verrà aperta. 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' da
|
|
<command>postmaster</command> e il suo significato è: "ascolta i
|
|
socket TCP/IP così come gli Unix domain socket".
|
|
<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 &</entry>
|
|
<entry>pg_connect("dbname=NomeMioDatabase");</entry>
|
|
<entry>OK</entry>
|
|
</row>
|
|
<row>
|
|
<entry>postmaster -i &</entry>
|
|
<entry>pg_connect("dbname=NomeMioDatabase");</entry>
|
|
<entry>OK</entry>
|
|
</row>
|
|
<row>
|
|
<entry>postmaster &</entry>
|
|
<entry>pg_connect("host=localhost dbname=NomeMioDatabase");</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.php on line 20.
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>postmaster -i &</entry>
|
|
<entry>pg_connect("host=localhost dbname=NomeMioDatabase");</entry>
|
|
<entry>OK</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</table>
|
|
</para>
|
|
<para>
|
|
Si può stabilire una connessione al server PostgreSQL usando le
|
|
seguenti coppie di valori impostate nella stringa di comando: <command>$conn =
|
|
pg_connect("host=IlMioHost port=LaMiaPorta tty=myTTY options=LeMieOpzioni
|
|
dbname=IlMioDB user=IlMioUtente password=LaMiaPassword ");
|
|
</command>
|
|
</para>
|
|
<para>
|
|
L'uso della sintassi in uso precedentemente:
|
|
<command>
|
|
$conn = pg_connect ("host", "port", "options", "tty", "dbname")
|
|
</command>
|
|
è deprecato.
|
|
</para>
|
|
<para>
|
|
Le variabili d'ambiente modificano il comportamento server/client di
|
|
PostgreSQL. Per esempio, il modulo PostgreSQL si baserà sulla variabile
|
|
PGHOST quando il nome dell'host è omesso nella stringa di
|
|
connessione. Le variabili d'ambiente riconosciute sono diverse da versione
|
|
a versione. Consultare il Manuale del Programmatore PostgreSQL (libpq -
|
|
Variabili d'Ambiente) per ulteriori dettagli.
|
|
</para>
|
|
<para>
|
|
Assicurarsi di aver impostato le variabili d'ambiente per l'utente appropriato. Usare
|
|
<literal>$_ENV</literal> o <function>getenv</function> per controllare
|
|
quali variabili d'ambiente sono disponibili al processo corrente.
|
|
</para>
|
|
<example>
|
|
<title>Impostazione dei parametri di default</title>
|
|
<programlisting>
|
|
<![CDATA[
|
|
PGHOST=pgsql.example.com
|
|
PGPORT=7890
|
|
PGDATABASE=web-system
|
|
PGUSER=web-user
|
|
PGPASSWORD=segreta
|
|
PGDATESTYLE=ISO
|
|
PGTZ=JST
|
|
PGCLIENTENCODING=EUC-JP
|
|
|
|
export PGHOST PGPORT PGDATABASE PGUSER PGPASSWORD PGDATESTYLE PGTZ PGCLIENTENCODING
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</section>
|
|
|
|
&reference.pgsql.constants;
|
|
|
|
<section id="pgsql.examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
A partire da PostgreSQL 7.1.0, il tipo di dato text ha 1GB come dimensione
|
|
massima. Nelle versioni più vecchie di PostgreSQL il tipo di dato text è limitato dalla dimensione
|
|
del block. (Default 8KB. Massimo 32KB, specificato al momento della compilazione)
|
|
</para>
|
|
<para>
|
|
Per usare l'interfaccia large object (lo), è necessario includerla entro
|
|
un blocco di una transazione. Un blocco di transazione inizia con un
|
|
comando SQL <command>BEGIN</command> e se la
|
|
transazione è stata valida, termina con <command>COMMIT</command> o
|
|
<command>END</command>. Se la transazione fallisce, essa
|
|
deve venire chiusa con <command>ROLLBACK</command> o
|
|
<command>ABORT</command>.
|
|
<example>
|
|
<title>Utilizzare Large Objects</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, "dati large object");
|
|
pg_lo_close ($handle);
|
|
pg_query ($database, "commit");
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
Non chiudere la risorsa di connessione prima di aver chiuso la risorsa
|
|
large object.
|
|
</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
|
|
-->
|