]>
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
49 var $commands = array(
50 'pconnect' => '$this->command_mysql_pconnect',
51 'connect' => '$this->command_mysql_connect',
52 'query' => '$this->command_mysql_query',
53 'error_num' => 'mysql_errno',
54 'error_str' => 'mysql_error',
55 'escape_string' => '$this->command_mysql_escape_string',
56 'fetch_assoc' => 'mysql_fetch_assoc',
57 'fetch_object' => 'mysql_fetch_object',
58 'free_result' => 'mysql_free_result',
59 'insert_id' => 'mysql_insert_id',
60 'num_rows' => 'mysql_num_rows',
61 'affected_rows' => 'mysql_affected_rows'
64 // ###################################################################
68 function __construct(&$registry)
70 parent
::__construct($registry);
73 // ###################################################################
77 function DB_MySQL(&$registry)
79 $this->__construct($registry);
82 // ###################################################################
84 * Wrapper: mysql_pconnect
88 * @param string Server name
89 * @param string User name
90 * @param string Password
91 * @param string Database
93 * @return integer DB-Link
95 function command_mysql_pconnect($server, $user, $password, $database)
97 $link = mysql_pconnect($server, $user, $password);
98 $this->select_db($database, $link);
103 // ###################################################################
105 * Wrapper: mysql_connect
109 * @param string Server name
110 * @param string User name
111 * @param string Password
112 * @param string Database
114 * @return integer DB-Link
116 function command_mysql_connect($server, $user, $password, $database)
118 $link = mysql_connect($server, $user, $password);
119 $this->select_db($database, $link);
124 // ###################################################################
126 * Wrapper: mysql_select_db
130 * @param string Database name
131 * @param integer DB-Link
133 function select_db($database, $link)
135 if (!mysql_select_db($database, $link))
137 $this->error('Cannot use the database \'' . $this->database
. '\'');
141 // ###################################################################
143 * Wrapper: mysql_query
147 * @param integer DB-Link
148 * @param string Query string
150 * @return integer Result
152 function command_mysql_query($link, $string)
154 return mysql_query($string, $link);
157 // ###################################################################
159 * Wrapper: mysql(_real)_escape_string
163 * @param integer DB-Link
164 * @param string Unescaped text
166 * @return string Escaped text
168 function command_mysql_escape_string($link, $string)
170 if (function_exists('mysql_real_escape_string'))
172 return mysql_real_escape_string($string, $link);
176 return mysql_escape_string($string);
181 /*=====================================================================*\
182 || ###################################################################
185 || ###################################################################
186 \*=====================================================================*/