]> src.bluestatic.org Git - isso.git/blob - DbMySqlI.php
Add a __toString() method on BSPrinterAbstract
[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 * Wrapper: mysql_connect
45 */
46 protected function _connect($server, $user, $password, $database)
47 {
48 return @mysqli_connect($server, $user, $password, $database);
49 }
50
51 /**
52 * Wrapper: mysql_query
53 */
54 protected function _query($string)
55 {
56 return mysqli_query($this->dblink, $string);
57 }
58
59 /**
60 * Wrapper: mysql_escape_string
61 */
62 protected function _escapeBinary($binary)
63 {
64 return mysqli_real_escape_string($this->dblink, $binary);
65 }
66
67 /**
68 * Wrapper: mysql(_real)_escape_string
69 */
70 protected function _escapeString($string)
71 {
72 return mysqli_real_escape_string($this->dblink, $string);
73 }
74
75 /**
76 * Not supported: unescape binary string
77 */
78 protected function _unescapeBinary($string)
79 {
80 return $string;
81 }
82
83 /**
84 * Wrapper: mysql_insert_id
85 */
86 protected function _insertId()
87 {
88 return mysqli_insert_id($this->dblink);
89 }
90
91 /**
92 * Wrapper: mysql_affected_rows
93 */
94 protected function _affectedRows($result)
95 {
96 return mysqli_affected_rows($this->dblink);
97 }
98
99 /**
100 * Starts a database transaction
101 */
102 public function begin()
103 {
104 $this->query("START TRANSACTION");
105 }
106
107 /**
108 * Reverts a transaction back to a given savepoint
109 */
110 public function rollback()
111 {
112 $this->query("ROLLBACK");
113 }
114
115 /**
116 * Commits a database transaction
117 */
118 public function commit()
119 {
120 $this->query("COMMIT");
121 }
122
123 /**
124 * Returns the error number
125 *
126 * @return integer Error number
127 */
128 public function _errorNumber()
129 {
130 return mysqli_errno($this->dblink);
131 }
132
133 /**
134 * Returns the error string
135 *
136 * @return string Error string
137 */
138 public function _errorString()
139 {
140 return mysqli_error($this->dblink);
141 }
142 }
143
144 /**
145 * Database Result
146 *
147 * This class holds result information for a database result
148 *
149 * @author rsesek
150 * @copyright Copyright (c)2005 - 2008, Blue Static
151 * @package ISSO
152 *
153 */
154 class BSDbMySqlIResult extends BSDbResult
155 {
156 /**
157 * Wrapper: mysql_fetch_assoc
158 */
159 protected function _fetchAssocArray($result)
160 {
161 return mysqli_fetch_assoc($result);
162 }
163
164 /**
165 * Wrapper: mysql_fetch_row
166 */
167 protected function _fetchRowArray($result)
168 {
169 return mysqli_fetch_row($result);
170 }
171
172 /**
173 * Wrapper: mysql_fetch_object
174 */
175 public function _fetchObject($result)
176 {
177 return mysqli_fetch_object($result);
178 }
179
180 /**
181 * Wrapper: mysql_free_result
182 */
183 protected function _freeResult($result)
184 {
185 mysqli_free_result($result);
186 }
187
188 /**
189 * Wrapper: mysql_num_rows
190 */
191 protected function _numRows($result)
192 {
193 return mysqli_num_rows($result);
194 }
195 }
196
197 ?>