'$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', 'escape_binary' => 'pg_escape_bytea', 'unescape_binary' => 'pg_unescape_bytea', 'fetch_assoc' => 'pg_fetch_assoc', 'fetch_row' => 'pg_fetch_row', '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 */ private $port = 5432; // ################################################################### /** * Sets the port number for the connection * * @param integer Port number */ public function setPort($port) { $this->port = $port; } // ################################################################### /** * Wrapper: pg_connect */ protected function _connect($server, $user, $password, $database) { return pg_connect("host='$server' port={$this->port} user='$user' password='$password' dbname='$database'"); } // ################################################################### /** * Wrapper: pg_pconnect */ protected function _pConnect($server, $user, $password, $database) { return pg_pconnect("host='$server' port={$this->port} user='$user' password='$password' dbname='$database'"); } // ################################################################### /** * Wrapper: pg_escape_string */ protected function _escapeString() { return pg_escape_string($string); } // ################################################################### /** * Wrapper/no support: error string */ protected function _errorString() { if ($this->result) { return pg_result_error($this->result); } return pg_last_error($this->dblink); } // ################################################################### /** * Not supported: error numbers */ protected function _errorNumber() { return -1; } // ################################################################### /** * Overload: insertId */ public function insertId($table, $field) { $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 */ public function transaction_start() { $this->query("BEGIN"); } // ################################################################### /** * Saves current transaction steps as a savepoint * * @param string Named savepoint */ public function transaction_savepoint($name) { $this->query("SAVEPOINT $name"); } // ################################################################### /** * Reverts a transaction back to a given savepoint * * @param string Named savepoint */ public function transaction_rollback($name = null) { $this->query("ROLLBACK" . ($name != null ? " TO $name" : "")); } // ################################################################### /** * Commits a database transaction */ public function transaction_commit() { $this->query("COMMIT"); } } /*=====================================================================*\ || ################################################################### || # $HeadURL$ || # $Id$ || ################################################################### \*=====================================================================*/ ?>