]>
src.bluestatic.org Git - isso.git/blob - db_postgresql.php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Iris Studios Shared Object Framework [#]version[#]
5 || # Copyright ©2002-[#]year[#] Iris Studios, Inc.
7 || # This program is free software; you can redistribute it and/or modify
8 || # it under the terms of the GNU General Public License as published by
9 || # the Free Software Foundation; version [#]gpl[#] of the License.
11 || # This program is distributed in the hope that it will be useful, but
12 || # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 || # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 || # You should have received a copy of the GNU General Public License along
17 || # with this program; if not, write to the Free Software Foundation, Inc.,
18 || # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 || ###################################################################
20 \*=====================================================================*/
23 * PostgreSQL Database Abstraction Layer
29 $this->load('db', null);
32 * PostgreSQL Database Abstraction Layer
34 * This framework is a function wrapper for PostgresQL functions so we can have
35 * better error reporting and query reporting.
37 * @author Iris Studios, Inc.
38 * @copyright Copyright ©2002 - [#]year[#], Iris Studios, Inc.
43 class DB_PostgreSQL
extends DB_Abstract
46 * Command mapping list
50 var $commands = array(
51 'pconnect' => '$this->command_pg_pconnect',
52 'connect' => '$this->command_pg_connect',
53 'query' => 'pg_query',
54 'error_num' => '$this->command_error_num',
55 'error_str' => '$this->command_error_str',
56 'escape_string' => '$this->command_pg_escape_string',
57 'fetch_assoc' => 'pg_fetch_assoc',
58 'fetch_object' => 'pg_fetch_object',
59 'free_result' => 'pg_free_result',
60 'insert_id' => '%link', // how do we support this...?
61 'num_rows' => 'pg_num_rows',
62 'affected_rows' => 'pg_affected_rows'
66 * Port number to connect to
73 * Fields array that is used in this module
78 'port' => array(REQ_NO
, null, true)
81 // ###################################################################
85 function __construct(&$registry)
87 parent
::__construct($registry);
90 // ###################################################################
94 function DB_PostgreSQL(&$registry)
96 $this->__construct($registry);
99 // ###################################################################
105 * @param string Field name
106 * @param mixed Value of the field
108 function set($name, $value)
110 $this->registry
->do_set($name, $value, 'db_postgresql');
113 // ###################################################################
115 * Wrapper: pg_connect
119 * @param string Server name
120 * @param string User name
121 * @param string Password
122 * @param string Database
124 * @return integer DB-Link
126 function command_pg_connect($server, $user, $password, $database)
128 $this->registry
->check_isso_fields(get_class($this));
129 return pg_connect("host='$server' port={$this->port} user='$user' password='$password' dbname='$database'");
132 // ###################################################################
134 * Wrapper: pg_pconnect
138 * @param string Server name
139 * @param string User name
140 * @param string Password
141 * @param string Database
143 * @return integer DB-Link
145 function command_pg_pconnect($server, $user, $password, $database)
147 $this->registry->check_isso_fields(get_class($this));
148 return pg_pconnect("host
='$server' port={$this->port} user='$user' password
='$password' dbname='$database'");
151 // ###################################################################
153 * Wrapper: pg_escape_string
157 * @param integer DB-Link (unused)
158 * @param string Raw string
160 * @return string Escaped string
162 function command_pg_escape_string($link, $string)
164 return pg_escape_string($string);
167 // ###################################################################
169 * Wrapper/no support: error string
173 * @param integer DB-Link
175 * @return string Error string
177 function command_error_str($link)
181 return pg_result_error($this->result
);
184 return pg_last_error($link);
187 // ###################################################################
189 * Not supported: error numbers
193 * @param integer DB-Link
195 * @return integer Returns -1 always
197 function command_error_num($link)
202 // ###################################################################
204 * Overload: insert_id
208 * @param integer Result
209 * @param string PostgreSQL sequence
211 * @return integer Insert ID
213 function insert_id($result, $sequence)
215 $temp = $this->query("SELECT currval($sequence) AS auto_inc");
216 //$temp = call_user_func($this->commands['query'], "SELECT currval($table_col)");
218 print_r($this->fetch_array($temp));
222 /*=====================================================================*\
223 || ###################################################################
226 || ###################################################################
227 \*=====================================================================*/