]>
src.bluestatic.org Git - isso.git/blob - db_mysql.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 * MySQL Database Abstraction Layer
29 $this->load('db', null);
32 * MySQL Database Abstraction Layer
34 * This framework is a function wrapper for MySQL 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_MySQL
extends DB_Abstract
46 * Command mapping list
50 var $commands = array(
51 'pconnect' => '$this->command_mysql_pconnect',
52 'connect' => '$this->command_mysql_connect',
53 'query' => '$this->command_mysql_query',
54 'error_num' => 'mysql_errno',
55 'error_str' => 'mysql_error',
56 'escape_string' => '$this->command_mysql_escape_string',
57 'fetch_assoc' => 'mysql_fetch_assoc',
58 'fetch_row' => 'mysql_fetch_row',
59 'fetch_object' => 'mysql_fetch_object',
60 'free_result' => 'mysql_free_result',
61 'insert_id' => 'mysql_insert_id',
62 'num_rows' => 'mysql_num_rows',
63 'affected_rows' => 'mysql_affected_rows'
66 // ###################################################################
70 function __construct(&$registry)
72 parent
::__construct($registry);
75 // ###################################################################
79 function DB_MySQL(&$registry)
81 $this->__construct($registry);
84 // ###################################################################
86 * Wrapper: mysql_pconnect
90 * @param string Server name
91 * @param string User name
92 * @param string Password
93 * @param string Database
95 * @return integer DB-Link
97 function command_mysql_pconnect($server, $user, $password, $database)
99 $link = mysql_pconnect($server, $user, $password);
100 $this->select_db($database, $link);
105 // ###################################################################
107 * Wrapper: mysql_connect
111 * @param string Server name
112 * @param string User name
113 * @param string Password
114 * @param string Database
116 * @return integer DB-Link
118 function command_mysql_connect($server, $user, $password, $database)
120 $link = mysql_connect($server, $user, $password);
121 $this->select_db($database, $link);
126 // ###################################################################
128 * Wrapper: mysql_select_db
132 * @param string Database name
133 * @param integer DB-Link
135 function select_db($database, $link)
137 if (!mysql_select_db($database, $link))
139 $this->error('Cannot use the database \'' . $this->database
. '\'');
143 // ###################################################################
145 * Wrapper: mysql_query
149 * @param integer DB-Link
150 * @param string Query string
152 * @return integer Result
154 function command_mysql_query($link, $string)
156 return mysql_query($string, $link);
159 // ###################################################################
161 * Wrapper: mysql(_real)_escape_string
165 * @param integer DB-Link
166 * @param string Unescaped text
168 * @return string Escaped text
170 function command_mysql_escape_string($link, $string)
172 if (function_exists('mysql_real_escape_string'))
174 return mysql_real_escape_string($string, $link);
178 return mysql_escape_string($string);
183 /*=====================================================================*\
184 || ###################################################################
187 || ###################################################################
188 \*=====================================================================*/