The DB::transaction_rollback() now has name as optional, to just rollback the entire...
[isso.git] / db_mysqli.php
1 <?php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Iris Studios Shared Object Framework [#]version[#]
5 || # Copyright ©2002-[#]year[#] Iris Studios, Inc.
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 Iris Studios, Inc.
38 * @copyright Copyright ©2002 - [#]year[#], Iris Studios, Inc.
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 * @access private
49 */
50 var $commands = array(
51 'pconnect' => '$this->command_mysqli_connect',
52 'connect' => '$this->command_mysqli_connect',
53 'query' => 'mysqli_query',
54 'error_num' => 'mysqli_errno',
55 'error_str' => 'mysqli_error',
56 'escape_string' => 'mysqli_real_escape_string',
57 'fetch_assoc' => 'mysqli_fetch_assoc',
58 'fetch_row' => 'mysqli_fetch_row',
59 'fetch_object' => 'mysqli_fetch_object',
60 'free_result' => 'mysqli_free_result',
61 'insert_id' => 'mysqli_insert_id',
62 'num_rows' => 'mysqli_num_rows',
63 'affected_rows' => 'mysqli_affected_rows'
64 );
65
66 // ###################################################################
67 /**
68 * Constructor
69 */
70 function __construct(&$registry)
71 {
72 parent::__construct($registry);
73 }
74
75 // ###################################################################
76 /**
77 * (PHP 4) Constructor
78 */
79 function DB_MySQLi(&$registry)
80 {
81 $this->__construct($registry);
82 }
83
84 // ###################################################################
85 /**
86 * Wrapper: mysqli_connect
87 *
88 * @access protected
89 *
90 * @param string Server name
91 * @param string User name
92 * @param string Password
93 * @param string Database
94 *
95 * @return integer DB-Link
96 */
97 function command_mysqli_connect($server, $user, $password, $database)
98 {
99 return mysqli_connect($server, $user, $password, $database);
100 }
101
102 // ###################################################################
103 /**
104 * Starts a database transaction
105 *
106 * @access public
107 */
108 function transaction_start()
109 {
110 $this->query("START TRANSACTION");
111 }
112
113 // ###################################################################
114 /**
115 * Saves current transaction steps as a savepoint
116 *
117 * @access public
118 *
119 * @param string Named savepoint
120 */
121 function transaction_savepoint($name)
122 {
123 $this->query("SAVEPOINT $name");
124 }
125
126 // ###################################################################
127 /**
128 * Reverts a transaction back to a given savepoint
129 *
130 * @access public
131 *
132 * @param string Named savepoint
133 */
134 function transaction_rollback($name = null)
135 {
136 $this->query("ROLLBACK" . ($name != null ? " TO SAVEPOINT $name" : ""));
137 }
138
139 // ###################################################################
140 /**
141 * Commits a database transaction
142 *
143 * @access public
144 */
145 function transaction_commit()
146 {
147 $this->query("COMMIT");
148 }
149 }
150
151 /*=====================================================================*\
152 || ###################################################################
153 || # $HeadURL$
154 || # $Id$
155 || ###################################################################
156 \*=====================================================================*/
157 ?>