This class is made by unreal4u (Camilo Sperberg) and based on the Extended MySQLi class made by the same author. It haves exactly the same methods so that migrating from MySQL to PostGreSQL won't be so hard to do.


In a glinch:


This package implements a PostGreSQL database access wrapper using the PDO extension.

There is class that manages PostGreSQL database access connections so only one connection is established during the same PHP script execution.

Another class implements other database access functions like executing queries with prepared queries, measuring the time the queries take to execute and the memory usage, retrieving query results into arrays, the number of result rows, last inserted record identifier and log executed queries to a valid XML log file or directly into your page.

If the query takes just too long, you can cache the query result into an XML file, and you can also handle errors.

This package has been extensivily tested with xDebug and Suhosin so that no errors are present.




define('DB_SHOW_ERRORS',TRUE); // Show DB connection error to users?
define('DB_LOG_XML',FALSE); // Log all database activity to XML?
define('DB_URL_XML','/home/user/db-log.xml'); // Location of XML file, recommended place is outside the public html directory!
define('DB_CACHE_LOCATION','cache/'); // Location of cache file(s), with trailing slash
define('DB_CACHE_EXPIRE','60'); // DB cache file expiricy, in seconds

define('PGSQL_HOST','localhost'); // your db's host
define('PGSQL_PORT',5432);        // your db's port
define('PGSQL_USER','test'); // your db's username
define('PGSQL_PASS','test'); // your db's password
define('PGSQL_NAME','test');   // your db's database name