Public Member Functions | |
__sleep () | |
This "magic" method is invoked upon serialize() and works in tandem with the __wakeup() method to ensure that your database connection is serializable. | |
__wakeup () | |
This "magic" method is invoked upon unserialize(). | |
getResource () | |
getDSN () | |
getFlags () | |
prepareCall ($sql) | |
Creates a CallableStatement object for calling database stored procedures. | |
supportsNestedTrans () | |
Driver classes should override this if they support transactions. | |
begin () | |
Begins a transaction (if supported). | |
commit () | |
Commits statements in a transaction. | |
rollback () | |
Rollback changes in a transaction. | |
setAutoCommit ($bit) | |
Enable/disable automatic commits. | |
getAutoCommit () | |
Get auto-commit status. | |
isConnected () | |
Returns false if connection is closed. | |
Protected Member Functions | |
beginTrans () | |
Begin new transaction. | |
commitTrans () | |
Commit the current transaction. | |
rollbackTrans () | |
Roll back (undo) the current transaction. | |
Protected Attributes | |
$transactionOpcount = 0 | |
$dblink | |
$dsn | |
$flags = 0 |
Definition at line 32 of file ConnectionCommon.php.
ConnectionCommon::__sleep | ( | ) |
This "magic" method is invoked upon serialize() and works in tandem with the __wakeup() method to ensure that your database connection is serializable.
This method returns an array containing the names of any members of your class which need to be serialized in order to allow the class to re-connect to the database when it is unserialized.
Developers:
Note that you cannot serialize resources (connection links) and expect them to be valid when you unserialize. For this reason, you must re-connect to the database in the __wakeup() method.
It's up to your class implimentation to ensure that the necessary data is serialized. You probably at least need to serialize:
(1) the DSN array used by connect() method (2) Any flags that were passed to the connection (3) Possibly the autocommit state
DriverManager::getConnection()
Definition at line 94 of file ConnectionCommon.php.
ConnectionCommon::__wakeup | ( | ) |
This "magic" method is invoked upon unserialize().
This method will re-connects to the database using the information that was stored using the __sleep() method.
Definition at line 105 of file ConnectionCommon.php.
ConnectionCommon::begin | ( | ) |
Begins a transaction (if supported).
Definition at line 157 of file ConnectionCommon.php.
References beginTrans(), and supportsNestedTrans().
Referenced by setAutoCommit().
00158 { 00159 if ($this->transactionOpcount === 0 || $this->supportsNestedTrans()) { 00160 $this->beginTrans(); 00161 } 00162 $this->transactionOpcount++; 00163 }
ConnectionCommon::beginTrans | ( | ) | [protected] |
Begin new transaction.
Driver classes should override this method if they support transactions.
Reimplemented in MSSQLConnection, MySQLConnection, MySQLiConnection, ODBCConnection, OCI8Connection, PgSQLConnection, and SQLiteConnection.
Definition at line 230 of file ConnectionCommon.php.
Referenced by begin().
ConnectionCommon::commit | ( | ) |
Commits statements in a transaction.
Definition at line 168 of file ConnectionCommon.php.
References commitTrans(), and supportsNestedTrans().
Referenced by setAutoCommit().
00169 { 00170 if ($this->transactionOpcount > 0) { 00171 if ($this->transactionOpcount == 1 || $this->supportsNestedTrans()) { 00172 $this->commitTrans(); 00173 } 00174 $this->transactionOpcount--; 00175 } 00176 }
ConnectionCommon::commitTrans | ( | ) | [protected] |
Commit the current transaction.
Driver classes should override this method if they support transactions.
Reimplemented in MSSQLConnection, MySQLConnection, MySQLiConnection, ODBCConnection, OCI8Connection, PgSQLConnection, and SQLiteConnection.
Definition at line 238 of file ConnectionCommon.php.
Referenced by commit().
ConnectionCommon::getAutoCommit | ( | ) |
ConnectionCommon::getDSN | ( | ) |
ConnectionCommon::getFlags | ( | ) |
ConnectionCommon::getResource | ( | ) |
ConnectionCommon::isConnected | ( | ) |
Returns false if connection is closed.
Definition at line 254 of file ConnectionCommon.php.
ConnectionCommon::prepareCall | ( | $ | sql | ) |
Creates a CallableStatement object for calling database stored procedures.
string | $sql |
Reimplemented in MSSQLConnection, MySQLConnection, MySQLiConnection, ODBCConnection, OCI8Connection, PgSQLConnection, and SQLiteConnection.
Definition at line 139 of file ConnectionCommon.php.
00140 { 00141 throw new SQLException("Current driver does not support stored procedures using CallableStatement."); 00142 }
ConnectionCommon::rollback | ( | ) |
Rollback changes in a transaction.
Definition at line 181 of file ConnectionCommon.php.
References rollbackTrans(), and supportsNestedTrans().
00182 { 00183 if ($this->transactionOpcount > 0) { 00184 if ($this->transactionOpcount == 1 || $this->supportsNestedTrans()) { 00185 $this->rollbackTrans(); 00186 } 00187 $this->transactionOpcount--; 00188 } 00189 }
ConnectionCommon::rollbackTrans | ( | ) | [protected] |
Roll back (undo) the current transaction.
Driver classes should override this method if they support transactions.
Reimplemented in MSSQLConnection, MySQLConnection, MySQLiConnection, ODBCConnection, OCI8Connection, PgSQLConnection, and SQLiteConnection.
Definition at line 246 of file ConnectionCommon.php.
Referenced by rollback().
ConnectionCommon::setAutoCommit | ( | $ | bit | ) |
Enable/disable automatic commits.
Pushes SQLWarning onto $warnings stack if the autocommit value is being changed mid-transaction. This function is overridden by driver classes so that they can perform the necessary begin/end transaction SQL.
If auto-commit is being set to TRUE, then the current transaction will be committed immediately.
boolean | $bit New value for auto commit. |
Definition at line 202 of file ConnectionCommon.php.
References begin(), and commit().
00203 { 00204 if ($this->transactionOpcount > 0) { 00205 trigger_error("Changing autocommit in mid-transaction; committing " . $this->transactionOpcount . " uncommitted statements.", E_USER_WARNING); 00206 } 00207 00208 if (!$bit) { 00209 $this->begin(); 00210 } 00211 else { 00212 $this->commit(); 00213 } 00214 }
ConnectionCommon::supportsNestedTrans | ( | ) |
Driver classes should override this if they support transactions.
Definition at line 149 of file ConnectionCommon.php.
Referenced by begin(), commit(), and rollback().
ConnectionCommon::$dblink [protected] |
Definition at line 53 of file ConnectionCommon.php.
ConnectionCommon::$dsn [protected] |
Definition at line 59 of file ConnectionCommon.php.
ConnectionCommon::$flags = 0 [protected] |
Definition at line 65 of file ConnectionCommon.php.
Referenced by SQLiteConnection::connect(), PgSQLConnection::connect(), OCI8Connection::connect(), ODBCConnection::connect(), MySQLiConnection::connect(), MySQLConnection::connect(), and MSSQLConnection::connect().
ConnectionCommon::$transactionOpcount = 0 [protected] |
Definition at line 47 of file ConnectionCommon.php.