Removing all the package replacement tags and SVN keyword tags
[isso.git] / DbMySqlI.php
1 <?php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Blue Static ISSO Framework
5 || # Copyright ©2002-2007 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 ©2002 - 2007, 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_fetch_assoc
91 */
92 protected function _fetchAssocArray($result)
93 {
94 return mysqli_fetch_assoc($result);
95 }
96
97 // ###################################################################
98 /**
99 * Wrapper: mysql_fetch_row
100 */
101 protected function _fetchRowArray($result)
102 {
103 return mysqli_fetch_row($result);
104 }
105
106 // ###################################################################
107 /**
108 * Wrapper: mysql_fetch_object
109 */
110 public function _fetchObject($result)
111 {
112 return mysqli_fetch_object($result);
113 }
114
115 // ###################################################################
116 /**
117 * Wrapper: mysql_free_result
118 */
119 protected function _freeResult($result)
120 {
121 mysqli_free_result($result);
122 }
123
124 // ###################################################################
125 /**
126 * Wrapper: mysql_insert_id
127 */
128 protected function _insertId()
129 {
130 return mysqli_insert_id($this->dblink);
131 }
132
133 // ###################################################################
134 /**
135 * Wrapper: mysql_num_rows
136 */
137 protected function _numRows($result)
138 {
139 return mysqli_num_rows($result);
140 }
141
142 // ###################################################################
143 /**
144 * Wrapper: mysql_affected_rows
145 */
146 protected function _affectedRows($result)
147 {
148 return mysqli_affected_rows($this->dblink);
149 }
150
151 // ###################################################################
152 /**
153 * Starts a database transaction
154 */
155 public function begin()
156 {
157 $this->query("START TRANSACTION");
158 }
159
160 // ###################################################################
161 /**
162 * Reverts a transaction back to a given savepoint
163 */
164 public function rollback()
165 {
166 $this->query("ROLLBACK");
167 }
168
169 // ###################################################################
170 /**
171 * Commits a database transaction
172 */
173 public function commit()
174 {
175 $this->query("COMMIT");
176 }
177
178 // ###################################################################
179 /**
180 * Returns the error number
181 *
182 * @return integer Error number
183 */
184 public function _errorNumber()
185 {
186 return mysqli_errno($this->dblink);
187 }
188
189 // ###################################################################
190 /**
191 * Returns the error string
192 *
193 * @return string Error string
194 */
195 public function _errorString()
196 {
197 return mysqli_error($this->dblink);
198 }
199 }
200
201 ?>