PostgreSQL Functions
PostgreSQL
&reftitle.intro;
PostgreSQL database is Open Source product and available without
cost. 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/SQL99 language support, transactions, referential integrity,
stored procedures and type extensibility. PostgreSQL is an open source
descendant of this original Berkeley code.
&reftitle.required;
To use PostgreSQL support, you need PostgreSQL 6.5 or
later, PostgreSQL 8.0 or later to enable all PostgreSQL module
features. PostgreSQL supports many character encodings including
multibyte character encoding. The current version and more
information about PostgreSQL is available at
&url.pgsql; and
the PostgreSQL Documentation.
&reference.pgsql.configure;
&reference.pgsql.ini;
&reftitle.resources;
There are two resource types used in the PostgreSQL module. The first one
is the link identifier for a database connection, the second a resource
which holds the result of a query.
&reference.pgsql.constants;
&reftitle.notes;
Not all functions are supported by all builds. It depends on your
libpq (The PostgreSQL C client library) version and how libpq is
compiled. If PHP PostgreSQL extensions are missing, then it is because
your libpq version does not support them.
Most PostgreSQL functions accept connection as
the first optional parameter. If it is not provided, the last opened
connection is used. If it doesn't exist, functions return &false;.
PostgreSQL automatically folds all identifiers (e.g. table/column names)
to lower-case values at object creation time and at query time.
To force the use of mixed or upper case identifiers, you must escape
the identifier using double quotes ("").
PostgreSQL does not have special commands for fetching database schema
information (eg. all the tables in the current database). Instead, there
is a standard schema named information_schema in
PostgreSQL 7.4 and above containing
system views with all the necessary information, in an easily
queryable form. See the PostgreSQL Documentation
for full details.
&reftitle.examples;
This simple example shows how to connect, execute a query, print
resulting rows and disconnect from a PostgreSQL database.
PostgreSQL extension overview example
\n";
while ($line = pg_fetch_array($result, null, PGSQL_ASSOC)) {
echo "\t\n";
foreach ($line as $col_value) {
echo "\t\t$col_value | \n";
}
echo "\t
\n";
}
echo "\n";
// Free resultset
pg_free_result($result);
// Closing connection
pg_close($dbconn);
?>
]]>
&reference.pgsql.functions;