From b17039b5360f7f1cd25d30c574747875db0d0ee2 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Fri, 23 Dec 2005 22:44:51 +0000 Subject: [PATCH] Adding pgsql layer --- db_postgresql.php | 182 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 182 insertions(+) create mode 100644 db_postgresql.php diff --git a/db_postgresql.php b/db_postgresql.php new file mode 100644 index 0000000..8677c5f --- /dev/null +++ b/db_postgresql.php @@ -0,0 +1,182 @@ +load('db', null); + +/** +* PostgreSQL Database Abstraction Layer +* +* This framework is a function wrapper for PostgresQL functions so we can have +* better error reporting and query reporting. +* +* @author Iris Studios, Inc. +* @copyright Copyright ©2002 - [#]year[#], Iris Studios, Inc. +* @version $Revision$ +* @package ISSO +* +*/ +class DB_PostgreSQL extends DB_Abstract +{ + /** + * Command mapping list + * @var array + */ + var $commands = array( + 'pconnect' => '$this->command_pg_pconnect', + 'connect' => '$this->command_pg_connect', + 'query' => 'pg_query', + 'error_num' => '$this->command_error_num', + 'error_str' => '$this->command_error_str', + 'escape_string' => '$this->command_pg_escape_string', + 'fetch_assoc' => 'pg_fetch_assoc', + 'fetch_object' => 'pg_fetch_object', + 'free_result' => 'pg_free_result', + 'insert_id' => '%link', // how do we support this...? + 'num_rows' => 'pg_num_rows', + 'affected_rows' => 'pg_affected_rows' + ); + + /** + * Port number to connect to + * @var integer + */ + var $port = 5432; + + // ################################################################### + /** + * Constructor + */ + function __construct(&$registry) + { + parent::__construct($registry); + } + + // ################################################################### + /** + * (PHP 4) Constructor + */ + function DB_PostgreSQL(&$registry) + { + $this->__construct($registry); + } + + // ################################################################### + /** + * Wrapper: pg_connect + * + * @access protected + * + * @param string Server name + * @param string User name + * @param string Password + * @param string Database + * + * @return integer DB-Link + */ + function command_pg_connect($server, $user, $password, $database) + { + return pg_connect("host='$server' port={$this->port} user='$user' password='$password' dbname='$database'"); + } + + // ################################################################### + /** + * Wrapper: pg_pconnect + * + * @access protected + * + * @param string Server name + * @param string User name + * @param string Password + * @param string Database + * + * @return integer DB-Link + */ + function command_pg_pconnect($server, $user, $password, $database) + { + return pg_pconnect("host='$server' port={$this->port} user='$user' password='$password' dbname='$database'"); + } + + // ################################################################### + /** + * Wrapper: pg_escape_string + * + * @access protected + * + * @param integer DB-Link (unused) + * @param string Raw string + * + * @return string Escaped string + */ + function command_pg_escape_string($link, $string) + { + return pg_escape_string($string); + } + + // ################################################################### + /** + * Wrapper/no support: error string + * + * @access protected + * + * @param integer DB-Link + * + * @return string Error string + */ + function command_error_str($link) + { + if ($this->result) + { + return pg_result_error($this->result); + } + + return pg_last_error($link); + } + + // ################################################################### + /** + * Not supported: error numbers + * + * @access protected + * + * @param integer DB-Link + * + * @return integer Returns -1 always + */ + function command_error_num($link) + { + return -1; + } +} + +/*=====================================================================*\ +|| ################################################################### +|| # $HeadURL$ +|| # $Id$ +|| ################################################################### +\*=====================================================================*/ +?> \ No newline at end of file -- 2.22.5