Fixing a documentation and error mistake that weren't fixed through our sesarch/repla...
[isso.git] / DbMySqlI.php
1 <?php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Blue Static ISSO Framework
5 || # Copyright (c)2005-2008 Blue Static
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 2 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 * MySQLi Database Layer (DbMySqlI.php)
24 *
25 * @package ISSO
26 */
27
28 require_once(ISSO . '/Db.php');
29
30 /**
31 * MySQLi Database Layer
32 *
33 * This framework is a function wrapper for MySQLi functions so we can have
34 * better error reporting and query reporting.
35 *
36 * @author Blue Static
37 * @copyright Copyright (c)2005 - 2008, Blue Static
38 * @package ISSO
39 *
40 */
41 class BSDbMySqlI extends BSDb
42 {
43 // ###################################################################
44 /**
45 * Wrapper: mysql_connect
46 */
47 protected function _connect($server, $user, $password, $database)
48 {
49 return @mysqli_connect($server, $user, $password, $database);
50 }
51
52 // ###################################################################
53 /**
54 * Wrapper: mysql_query
55 */
56 protected function _query($string)
57 {
58 return mysqli_query($this->dblink, $string);
59 }
60
61 // ###################################################################
62 /**
63 * Wrapper: mysql_escape_string
64 */
65 protected function _escapeBinary($binary)
66 {
67 return mysqli_real_escape_string($this->dblink, $binary);
68 }
69
70 // ###################################################################
71 /**
72 * Wrapper: mysql(_real)_escape_string
73 */
74 protected function _escapeString($string)
75 {
76 return mysqli_real_escape_string($this->dblink, $string);
77 }
78
79 // ###################################################################
80 /**
81 * Not supported: unescape binary string
82 */
83 protected function _unescapeBinary($string)
84 {
85 return $string;
86 }
87
88 // ###################################################################
89 /**
90 * Wrapper: mysql_insert_id
91 */
92 protected function _insertId()
93 {
94 return mysqli_insert_id($this->dblink);
95 }
96
97 // ###################################################################
98 /**
99 * Wrapper: mysql_affected_rows
100 */
101 protected function _affectedRows($result)
102 {
103 return mysqli_affected_rows($this->dblink);
104 }
105
106 // ###################################################################
107 /**
108 * Starts a database transaction
109 */
110 public function begin()
111 {
112 $this->query("START TRANSACTION");
113 }
114
115 // ###################################################################
116 /**
117 * Reverts a transaction back to a given savepoint
118 */
119 public function rollback()
120 {
121 $this->query("ROLLBACK");
122 }
123
124 // ###################################################################
125 /**
126 * Commits a database transaction
127 */
128 public function commit()
129 {
130 $this->query("COMMIT");
131 }
132
133 // ###################################################################
134 /**
135 * Returns the error number
136 *
137 * @return integer Error number
138 */
139 public function _errorNumber()
140 {
141 return mysqli_errno($this->dblink);
142 }
143
144 // ###################################################################
145 /**
146 * Returns the error string
147 *
148 * @return string Error string
149 */
150 public function _errorString()
151 {
152 return mysqli_error($this->dblink);
153 }
154 }
155
156 /**
157 * Database Result
158 *
159 * This class holds result information for a database result
160 *
161 * @author rsesek
162 * @copyright Copyright (c)2005 - 2008, Blue Static
163 * @package ISSO
164 *
165 */
166 class BSDbMySqlIResult extends BSDbResult
167 {
168 // ###################################################################
169 /**
170 * Wrapper: mysql_fetch_assoc
171 */
172 protected function _fetchAssocArray($result)
173 {
174 return mysqli_fetch_assoc($result);
175 }
176
177 // ###################################################################
178 /**
179 * Wrapper: mysql_fetch_row
180 */
181 protected function _fetchRowArray($result)
182 {
183 return mysqli_fetch_row($result);
184 }
185
186 // ###################################################################
187 /**
188 * Wrapper: mysql_fetch_object
189 */
190 public function _fetchObject($result)
191 {
192 return mysqli_fetch_object($result);
193 }
194
195 // ###################################################################
196 /**
197 * Wrapper: mysql_free_result
198 */
199 protected function _freeResult($result)
200 {
201 mysqli_free_result($result);
202 }
203
204 // ###################################################################
205 /**
206 * Wrapper: mysql_num_rows
207 */
208 protected function _numRows($result)
209 {
210 return mysqli_num_rows($result);
211 }
212 }
213
214 ?>