From a6073a2166be5bc4be39d7bb2520ec7534bbd05d Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sun, 17 Dec 2006 00:04:53 +0000 Subject: [PATCH] Finished updating DbPgSql --- db_postgresql.php | 164 ++++++++++++++++++++++------------------------ 1 file changed, 78 insertions(+), 86 deletions(-) diff --git a/db_postgresql.php b/db_postgresql.php index 3ba5157..e52c50a 100644 --- a/db_postgresql.php +++ b/db_postgresql.php @@ -20,18 +20,17 @@ \*=====================================================================*/ /** -* PostgreSQL Database Abstraction Layer -* db_postgresql.php +* PostgreSQL Database Layer (DbPostgreSql.php) * * @package ISSO */ -$this->load('db', null); +require_once('ISSO/Db.php'); /** -* PostgreSQL Database Abstraction Layer +* PostgreSQL Database Layer * -* This framework is a function wrapper for PostgresQL functions so we can have +* This framework is a function wrapper for PostgreSQL functions so we can have * better error reporting and query reporting. * * @author Blue Static @@ -40,13 +39,13 @@ $this->load('db', null); * @package ISSO * */ -class DB_PostgreSQL extends DB_Abstract +class BSDbPostgreSql extends BSDb { /** * Command mapping list * @var array */ - private $commands = array( + protected $commands = array( 'pconnect' => '$this->command_pg_pconnect', 'connect' => '$this->command_pg_connect', 'query' => 'pg_query', @@ -70,93 +69,40 @@ class DB_PostgreSQL extends DB_Abstract */ private $port = 5432; - /** - * Fields array that is used in this module - * @var array - */ - private $fields = array( - 'port' => array(REQ_NO, null, true) - ); - - // ################################################################### - /** - * Constructor - */ - public function __construct(&$registry) - { - parent::__construct($registry); - } - - // ################################################################### - /** - * Sets an ISSO field - * - * @param string Field name - * @param mixed Value of the field - */ - public function set($name, $value) - { - $this->registry->do_set($name, $value, 'db_postgresql'); - } - // ################################################################### /** - * Gets an ISSO field + * Sets the port number for the connection * - * @param string Field name - * - * @return mixed Value of the field + * @param integer Port number */ - public function get($fieldname) + public function setPort($port) { - return $this->registry->do_get($fieldname, 'db_postgresql'); + $this->port = $port; } - // ################################################################### /** * Wrapper: pg_connect - * - * @param string Server name - * @param string User name - * @param string Password - * @param string Database - * - * @return integer DB-Link */ - protected function command_pg_connect($server, $user, $password, $database) + protected function _connect($server, $user, $password, $database) { - $this->registry->check_isso_fields(get_class($this)); return pg_connect("host='$server' port={$this->port} user='$user' password='$password' dbname='$database'"); } // ################################################################### /** * Wrapper: pg_pconnect - * - * @param string Server name - * @param string User name - * @param string Password - * @param string Database - * - * @return integer DB-Link */ - protected function command_pg_pconnect($server, $user, $password, $database) + protected function _pConnect($server, $user, $password, $database) { - $this->registry->check_isso_fields(get_class($this)); return pg_pconnect("host='$server' port={$this->port} user='$user' password='$password' dbname='$database'"); } // ################################################################### /** * Wrapper: pg_escape_string - * - * @param integer DB-Link (unused) - * @param string Raw string - * - * @return string Escaped string */ - protected function command_pg_escape_string($link, $string) + protected function _escapeString() { return pg_escape_string($string); } @@ -164,49 +110,95 @@ class DB_PostgreSQL extends DB_Abstract // ################################################################### /** * Wrapper/no support: error string - * - * @param integer DB-Link - * - * @return string Error string */ - protected function command_error_str($link) + protected function _errorString() { if ($this->result) { return pg_result_error($this->result); } - return pg_last_error($link); + return pg_last_error($this->dblink); } // ################################################################### /** * Not supported: error numbers - * - * @param integer DB-Link - * - * @return integer Returns -1 always */ - protected function command_error_num($link) + protected function _errorNumber() { return -1; } // ################################################################### /** - * Overload: insert_id - * - * @param string Table name - * @param string Auto-up field - * - * @return integer Insert ID + * Overload: insertId */ - public function insert_id($table, $field) + public function insertId($table, $field) { - $temp = $this->query_first("SELECT last_value FROM {$table}_{$field}_seq"); + $temp = $this->queryFirst("SELECT last_value FROM {$table}_{$field}_seq"); return $temp['last_value']; } + protected function _insertId() + { + // we never get here + } + + // ################################################################### + /** + * Wrapper: pg_fetch_assoc + */ + protected function _fetchAssocArray($result) + { + return pg_fetch_assoc($result); + } + + // ################################################################### + /** + * Wrapper: pg_fetch_row + */ + protected function _fetchRowArray($result) + { + return pg_fetch_row($result); + } + + // ################################################################### + /** + * Wrapper: pg_fetch_object + */ + public function _fetchObject($result) + { + return pg_fetch_object($result); + } + + // ################################################################### + /** + * Wrapper: pg_free_result + */ + protected function _freeResult($result) + { + pg_free_result($result); + } + + // ################################################################### + /** + * Wrapper: pg_num_rows + */ + protected function _numRows($result) + { + return pg_num_rows($result); + } + + // ################################################################### + /** + * Wrapper: pg_affected_rows + */ + protected function _affectedRows($result) + { + return PG_AFFECTED_ROWS($result); + } + // ################################################################### /** * Starts a database transaction -- 2.43.5