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 * Wrapper: mysql_fetch_assoc
92 protected function _fetchAssocArray($result)
94 return mysqli_fetch_assoc($result);
97 // ###################################################################
99 * Wrapper: mysql_fetch_row
101 protected function _fetchRowArray($result)
103 return mysqli_fetch_row($result);
106 // ###################################################################
108 * Wrapper: mysql_fetch_object
110 public function _fetchObject($result)
112 return mysqli_fetch_object($result);
115 // ###################################################################
117 * Wrapper: mysql_free_result
119 protected function _freeResult($result)
121 mysqli_free_result($result);
124 // ###################################################################
126 * Wrapper: mysql_insert_id
128 protected function _insertId()
130 return mysqli_insert_id($this->dblink
);
133 // ###################################################################
135 * Wrapper: mysql_num_rows
137 protected function _numRows($result)
139 return mysqli_num_rows($result);
142 // ###################################################################
144 * Wrapper: mysql_affected_rows
146 protected function _affectedRows($result)
148 return mysqli_affected_rows($this->dblink
);
151 // ###################################################################
153 * Starts a database transaction
155 public function begin()
157 $this->query("START TRANSACTION");
160 // ###################################################################
162 * Reverts a transaction back to a given savepoint
164 public function rollback()
166 $this->query("ROLLBACK");
169 // ###################################################################
171 * Commits a database transaction
173 public function commit()
175 $this->query("COMMIT");
178 // ###################################################################
180 * Returns the error number
182 * @return integer Error number
184 public function _errorNumber()
186 return mysqli_errno($this->dblink
);
189 // ###################################################################
191 * Returns the error string
193 * @return string Error string
195 public function _errorString()
197 return mysqli_error($this->dblink
);