]>
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_object' => 'mysql_fetch_object',
59 'free_result' => 'mysql_free_result',
60 'insert_id' => 'mysql_insert_id',
61 'num_rows' => 'mysql_num_rows',
62 'affected_rows' => 'mysql_affected_rows'
65 // ###################################################################
69 function __construct(&$registry)
71 parent
::__construct($registry);
74 // ###################################################################
78 function DB_MySQL(&$registry)
80 $this->__construct($registry);
83 // ###################################################################
85 * Wrapper: mysql_pconnect
89 * @param string Server name
90 * @param string User name
91 * @param string Password
92 * @param string Database
94 * @return integer DB-Link
96 function command_mysql_pconnect($server, $user, $password, $database)
98 $link = mysql_pconnect($server, $user, $password);
99 $this->select_db($database, $link);
104 // ###################################################################
106 * Wrapper: mysql_connect
110 * @param string Server name
111 * @param string User name
112 * @param string Password
113 * @param string Database
115 * @return integer DB-Link
117 function command_mysql_connect($server, $user, $password, $database)
119 $link = mysql_connect($server, $user, $password);
120 $this->select_db($database, $link);
125 // ###################################################################
127 * Wrapper: mysql_select_db
131 * @param string Database name
132 * @param integer DB-Link
134 function select_db($database, $link)
136 if (!mysql_select_db($database, $link))
138 $this->error('Cannot use the database \'' . $this->database
. '\'');
142 // ###################################################################
144 * Wrapper: mysql_query
148 * @param integer DB-Link
149 * @param string Query string
151 * @return integer Result
153 function command_mysql_query($link, $string)
155 return mysql_query($string, $link);
158 // ###################################################################
160 * Wrapper: mysql(_real)_escape_string
164 * @param integer DB-Link
165 * @param string Unescaped text
167 * @return string Escaped text
169 function command_mysql_escape_string($link, $string)
171 if (function_exists('mysql_real_escape_string'))
173 return mysql_real_escape_string($string, $link);
177 return mysql_escape_string($string);
182 /*=====================================================================*\
183 || ###################################################################
186 || ###################################################################
187 \*=====================================================================*/