PostgreSQL functionsPHP ManualPrevNextXLIII. PostgreSQL functions
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.
PostgreSQL is available without cost. The current version is
available at www.PostgreSQL.org.
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 /tmp/.s.PGSQL.5432.
This option can be enabled with the '-i' flag to postmaster
and it's meaning is: "listen on TCP/IP sockets as well as
Unix domain sockets".
Table 1. Postmaster and PHPPostmasterPHPStatuspostmaster &pg_connect("", "", "", "", "dbname");OKpostmaster -i &pg_connect("", "", "", "", "dbname");OKpostmaster &pg_connect("localhost", "", "", "", "dbname");
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.
postmaster -i &pg_connect("localhost", "", "", "", "dbname");OK
One can also establish a connection with the following command:
$conn = pg_Connect("host=localhost port=5432
dbname=chris");
To use the large object (lo) interface, it is necessary to enclose
it within a transaction block. A transaction block starts with a
begin and if the transaction was valid ends
with commit and end. If the
transaction fails the transaction should be closed with
abort and rollback.
Example 1. Using Large Objects 1
2 <?php
3 $database = pg_Connect ("", "", "", "", "jacarta");
4 pg_exec ($database, "begin");
5 $oid = pg_locreate ($database);
6 echo ("$oid\n");
7 $handle = pg_loopen ($database, $oid, "w");
8 echo ("$handle\n");
9 pg_lowrite ($handle, "gaga");
10 pg_loclose ($handle);
11 pg_exec ($database, "commit")
12 pg_exec ($database, "end")
13 ?>
14
Table of Contentspg_Close — closes a PostgreSQL connectionpg_cmdTuples — returns number of affected tuplespg_Connect — opens a connectionpg_DBname — database namepg_ErrorMessage — error messagepg_Exec — execute a querypg_Fetch_Array — fetch row as arraypg_Fetch_Object — fetch row as objectpg_Fetch_Row — get row as enumerated arraypg_FieldIsNull — Test if a field is NULLpg_FieldName — Returns the name of a fieldpg_FieldNum — Returns the number of a columnpg_FieldPrtLen — Returns the printed lengthpg_FieldSize —
Returns the internal storage size of the named field
pg_FieldType —
Returns the type name for the corresponding field number
pg_FreeResult — Frees up memorypg_GetLastOid — Returns the last object identifierpg_Host — Returns the host namepg_loclose — close a large objectpg_locreate — create a large objectpg_loopen — open a large objectpg_loread — read a large objectpg_loreadall — read a entire large objectpg_lounlink — delete a large objectpg_lowrite — write a large objectpg_NumFields — Returns the number of fieldspg_NumRows — Returns the number of rowspg_Options — Returns optionspg_pConnect —
Make a persistent database connection
pg_Port — Returns the port numberpg_Result — Returns values from a result identifierpg_tty — Returns the tty namePrevHomeNextposix_getrlimitUppg_Close
Wyszukiwarka
Podobne podstrony:
ref pgsqlref pgsqlref oracleref mathref miscref xmlref sybasepercepcja refref dbxref dbmref ingresref overloadref xmlrpcref execref aspellref oracleRef B2 Fechnerref mssqlrefwięcej podobnych podstron