Removing the PHP4 constructors
[isso.git] / db_mysqli.php
1 <?php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Blue Static ISSO Framework [#]issoversion[#]
5 || # Copyright ©2002-[#]year[#] 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 [#]gpl[#] 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 Abstraction Layer
24 * db_mysqli.php
25 *
26 * @package ISSO
27 */
28
29 $this->load('db', null);
30
31 /**
32 * MySQLi Database Abstraction Layer
33 *
34 * This framework is a function wrapper for MySQLi functions so we can have
35 * better error reporting and query reporting.
36 *
37 * @author Blue Static
38 * @copyright Copyright ©2002 - [#]year[#], Blue Static
39 * @version $Revision$
40 * @package ISSO
41 *
42 */
43 class DB_MySQLi extends DB_Abstract
44 {
45 /**
46 * Command mapping list
47 * @var array
48 */
49 private $commands = array(
50 'pconnect' => '$this->command_mysqli_connect',
51 'connect' => '$this->command_mysqli_connect',
52 'query' => 'mysqli_query',
53 'error_num' => 'mysqli_errno',
54 'error_str' => 'mysqli_error',
55 'escape_string' => 'mysqli_real_escape_string',
56 'escape_binary' => 'mysqli_real_escape_string',
57 'unescape_binary' => '$this->command_unescape_binary',
58 'fetch_assoc' => 'mysqli_fetch_assoc',
59 'fetch_row' => 'mysqli_fetch_row',
60 'fetch_object' => 'mysqli_fetch_object',
61 'free_result' => 'mysqli_free_result',
62 'insert_id' => 'mysqli_insert_id',
63 'num_rows' => 'mysqli_num_rows',
64 'affected_rows' => 'mysqli_affected_rows'
65 );
66
67 // ###################################################################
68 /**
69 * Constructor
70 */
71 function __construct(&$registry)
72 {
73 parent::__construct($registry);
74 }
75
76 // ###################################################################
77 /**
78 * Wrapper: mysqli_connect
79 *
80 * @access protected
81 *
82 * @param string Server name
83 * @param string User name
84 * @param string Password
85 * @param string Database
86 *
87 * @return integer DB-Link
88 */
89 function command_mysqli_connect($server, $user, $password, $database)
90 {
91 return mysqli_connect($server, $user, $password, $database);
92 }
93
94 // ###################################################################
95 /**
96 * Not supported: unescape binary string
97 *
98 * @access protected
99 *
100 * @param string Escaped data
101 *
102 * @return string Same data
103 */
104 function command_unescape_binary($string)
105 {
106 return $string;
107 }
108
109 // ###################################################################
110 /**
111 * Starts a database transaction
112 *
113 * @access public
114 */
115 function transaction_start()
116 {
117 $this->query("START TRANSACTION");
118 }
119
120 // ###################################################################
121 /**
122 * Saves current transaction steps as a savepoint
123 *
124 * @access public
125 *
126 * @param string Named savepoint
127 */
128 function transaction_savepoint($name)
129 {
130 $this->query("SAVEPOINT $name");
131 }
132
133 // ###################################################################
134 /**
135 * Reverts a transaction back to a given savepoint
136 *
137 * @access public
138 *
139 * @param string Named savepoint
140 */
141 function transaction_rollback($name = null)
142 {
143 $this->query("ROLLBACK" . ($name != null ? " TO SAVEPOINT $name" : ""));
144 }
145
146 // ###################################################################
147 /**
148 * Commits a database transaction
149 *
150 * @access public
151 */
152 function transaction_commit()
153 {
154 $this->query("COMMIT");
155 }
156 }
157
158 /*=====================================================================*\
159 || ###################################################################
160 || # $HeadURL$
161 || # $Id$
162 || ###################################################################
163 \*=====================================================================*/
164 ?>