Give all the instance variables visibility tags
[isso.git] / db_mysql.php
1 <?php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Iris Studios Shared Object Framework [#]version[#]
5 || # Copyright ©2002-[#]year[#] Iris Studios, Inc.
6 || #
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.
10 || #
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
14 || # more details.
15 || #
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 \*=====================================================================*/
21
22 /**
23 * MySQL Database Abstraction Layer
24 * db_mysql.php
25 *
26 * @package ISSO
27 */
28
29 $this->load('db', null);
30
31 /**
32 * MySQL Database Abstraction Layer
33 *
34 * This framework is a function wrapper for MySQL functions so we can have
35 * better error reporting and query reporting.
36 *
37 * @author Iris Studios, Inc.
38 * @copyright Copyright ©2002 - [#]year[#], Iris Studios, Inc.
39 * @version $Revision$
40 * @package ISSO
41 *
42 */
43 class DB_MySQL extends DB_Abstract
44 {
45 /**
46 * Command mapping list
47 * @var array
48 * @access private
49 */
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'
63 );
64
65 // ###################################################################
66 /**
67 * Constructor
68 */
69 function __construct(&$registry)
70 {
71 parent::__construct($registry);
72 }
73
74 // ###################################################################
75 /**
76 * (PHP 4) Constructor
77 */
78 function DB_MySQL(&$registry)
79 {
80 $this->__construct($registry);
81 }
82
83 // ###################################################################
84 /**
85 * Wrapper: mysql_pconnect
86 *
87 * @access protected
88 *
89 * @param string Server name
90 * @param string User name
91 * @param string Password
92 * @param string Database
93 *
94 * @return integer DB-Link
95 */
96 function command_mysql_pconnect($server, $user, $password, $database)
97 {
98 $link = mysql_pconnect($server, $user, $password);
99 $this->select_db($database, $link);
100
101 return $link;
102 }
103
104 // ###################################################################
105 /**
106 * Wrapper: mysql_connect
107 *
108 * @access protected
109 *
110 * @param string Server name
111 * @param string User name
112 * @param string Password
113 * @param string Database
114 *
115 * @return integer DB-Link
116 */
117 function command_mysql_connect($server, $user, $password, $database)
118 {
119 $link = mysql_connect($server, $user, $password);
120 $this->select_db($database, $link);
121
122 return $link;
123 }
124
125 // ###################################################################
126 /**
127 * Wrapper: mysql_select_db
128 *
129 * @access protected
130 *
131 * @param string Database name
132 * @param integer DB-Link
133 */
134 function select_db($database, $link)
135 {
136 if (!mysql_select_db($database, $link))
137 {
138 $this->error('Cannot use the database \'' . $this->database . '\'');
139 }
140 }
141
142 // ###################################################################
143 /**
144 * Wrapper: mysql_query
145 *
146 * @access protected
147 *
148 * @param integer DB-Link
149 * @param string Query string
150 *
151 * @return integer Result
152 */
153 function command_mysql_query($link, $string)
154 {
155 return mysql_query($string, $link);
156 }
157
158 // ###################################################################
159 /**
160 * Wrapper: mysql(_real)_escape_string
161 *
162 * @access protected
163 *
164 * @param integer DB-Link
165 * @param string Unescaped text
166 *
167 * @return string Escaped text
168 */
169 function command_mysql_escape_string($link, $string)
170 {
171 if (function_exists('mysql_real_escape_string'))
172 {
173 return mysql_real_escape_string($string, $link);
174 }
175 else
176 {
177 return mysql_escape_string($string);
178 }
179 }
180 }
181
182 /*=====================================================================*\
183 || ###################################################################
184 || # $HeadURL$
185 || # $Id$
186 || ###################################################################
187 \*=====================================================================*/
188 ?>