2 /*=====================================================================*\
3 || ###################################################################
4 || # Blue Static ISSO Framework
5 || # Copyright (c)2002-2007 Blue Static
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.
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 * MySQLi Database Layer (DbMySqlI.php)
28 require_once('ISSO/Db.php');
31 * MySQLi Database Layer
33 * This framework is a function wrapper for MySQLi functions so we can have
34 * better error reporting and query reporting.
37 * @copyright Copyright (c)2002 - 2007, Blue Static
41 class BSDbMySqlI
extends BSDb
43 // ###################################################################
45 * Wrapper: mysql_connect
47 protected function _connect($server, $user, $password, $database)
49 return @mysqli_connect($server, $user, $password, $database);
52 // ###################################################################
54 * Wrapper: mysql_query
56 protected function _query($string)
58 return mysqli_query($this->dblink
, $string);
61 // ###################################################################
63 * Wrapper: mysql_escape_string
65 protected function _escapeBinary($binary)
67 return mysqli_real_escape_string($this->dblink
, $binary);
70 // ###################################################################
72 * Wrapper: mysql(_real)_escape_string
74 protected function _escapeString($string)
76 return mysqli_real_escape_string($this->dblink
, $string);
79 // ###################################################################
81 * Not supported: unescape binary string
83 protected function _unescapeBinary($string)
88 // ###################################################################
90 * Starts a database transaction
92 public function begin()
94 $this->query("START TRANSACTION");
97 // ###################################################################
99 * Reverts a transaction back to a given savepoint
101 public function rollback()
103 $this->query("ROLLBACK");
106 // ###################################################################
108 * Commits a database transaction
110 public function commit()
112 $this->query("COMMIT");
115 // ###################################################################
117 * Returns the error number
119 * @return integer Error number
121 public function _errorNumber()
123 return mysqli_errno($this->dblink
);
126 // ###################################################################
128 * Returns the error string
130 * @return string Error string
132 public function _errorString()
134 return mysqli_error($this->dblink
);
141 * This class holds result information for a database result
144 * @copyright Copyright (c)2002 - 2007, Blue Static
148 class BSDbMySqlIResult
extends BSDbResult
150 // ###################################################################
152 * Wrapper: mysql_fetch_assoc
154 protected function _fetchAssocArray($result)
156 return mysqli_fetch_assoc($result);
159 // ###################################################################
161 * Wrapper: mysql_fetch_row
163 protected function _fetchRowArray($result)
165 return mysqli_fetch_row($result);
168 // ###################################################################
170 * Wrapper: mysql_fetch_object
172 public function _fetchObject($result)
174 return mysqli_fetch_object($result);
177 // ###################################################################
179 * Wrapper: mysql_free_result
181 protected function _freeResult($result)
183 mysqli_free_result($result);
186 // ###################################################################
188 * Wrapper: mysql_insert_id
190 protected function _insertId()
192 return mysqli_insert_id($this->dblink
);
195 // ###################################################################
197 * Wrapper: mysql_num_rows
199 protected function _numRows($result)
201 return mysqli_num_rows($result);
204 // ###################################################################
206 * Wrapper: mysql_affected_rows
208 protected function _affectedRows($result)
210 return mysqli_affected_rows($this->dblink
);