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
49 var $commands = array(
50 'pconnect' => '$this->command_pg_pconnect',
51 'connect' => '$this->command_pg_connect',
52 'query' => 'pg_query',
53 'error_num' => '$this->command_error_num',
54 'error_str' => '$this->command_error_str',
55 'escape_string' => '$this->command_pg_escape_string',
56 'fetch_assoc' => 'pg_fetch_assoc',
57 'fetch_object' => 'pg_fetch_object',
58 'free_result' => 'pg_free_result',
59 'insert_id' => '%link', // how do we support this...?
60 'num_rows' => 'pg_num_rows',
61 'affected_rows' => 'pg_affected_rows'
65 * Port number to connect to
70 // ###################################################################
74 function __construct(&$registry)
76 parent
::__construct($registry);
79 // ###################################################################
83 function DB_PostgreSQL(&$registry)
85 $this->__construct($registry);
88 // ###################################################################
94 * @param string Server name
95 * @param string User name
96 * @param string Password
97 * @param string Database
99 * @return integer DB-Link
101 function command_pg_connect($server, $user, $password, $database)
103 return pg_connect("host='$server' port={$this->port} user='$user' password='$password' dbname='$database'");
106 // ###################################################################
108 * Wrapper: pg_pconnect
112 * @param string Server name
113 * @param string User name
114 * @param string Password
115 * @param string Database
117 * @return integer DB-Link
119 function command_pg_pconnect($server, $user, $password, $database)
121 return pg_pconnect("host='$server' port={$this->port} user='$user' password='$password' dbname='$database'");
124 // ###################################################################
126 * Wrapper: pg_escape_string
130 * @param integer DB-Link (unused)
131 * @param string Raw string
133 * @return string Escaped string
135 function command_pg_escape_string($link, $string)
137 return pg_escape_string($string);
140 // ###################################################################
142 * Wrapper/no support: error string
146 * @param integer DB-Link
148 * @return string Error string
150 function command_error_str($link)
154 return pg_result_error($this->result
);
157 return pg_last_error($link);
160 // ###################################################################
162 * Not supported: error numbers
166 * @param integer DB-Link
168 * @return integer Returns -1 always
170 function command_error_num($link)
176 /*=====================================================================*\
177 || ###################################################################
180 || ###################################################################
181 \*=====================================================================*/