mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-09 12:02:24 +09:00
Updated DB classes to support multiple database connection strings - for when replication is used.
git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@8808 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
ee1a615008
commit
bb95345fb2
12 changed files with 576 additions and 680 deletions
|
|
@ -19,7 +19,7 @@
|
|||
$this->_setDBInfo();
|
||||
$this->_connect();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief create an instance of this class
|
||||
*/
|
||||
|
|
@ -31,37 +31,36 @@
|
|||
/**
|
||||
* @brief DB disconnection
|
||||
**/
|
||||
function close() {
|
||||
if(!$this->isConnected()) return;
|
||||
$this->_query("commit");
|
||||
@mysql_close($this->fd);
|
||||
function _close($connection) {
|
||||
$this->_query("commit", $connection);
|
||||
@mysql_close($connection);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Begin transaction
|
||||
**/
|
||||
function begin() {
|
||||
if(!$this->isConnected() || $this->transaction_started) return;
|
||||
$this->transaction_started = true;
|
||||
$this->_query("begin");
|
||||
function _begin() {
|
||||
$connection = $this->_getConnection('master');
|
||||
$this->_query("begin", $connection);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Rollback
|
||||
**/
|
||||
function rollback() {
|
||||
if(!$this->isConnected() || !$this->transaction_started) return;
|
||||
$this->_query("rollback");
|
||||
$this->transaction_started = false;
|
||||
function _rollback() {
|
||||
$connection = $this->_getConnection('master');
|
||||
$this->_query("rollback", $connection);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Commits
|
||||
**/
|
||||
function commit($force = false) {
|
||||
if(!$force && (!$this->isConnected() || !$this->transaction_started)) return;
|
||||
$this->_query("commit");
|
||||
$this->transaction_started = false;
|
||||
function _commit() {
|
||||
$connection = $this->_getConnection('master');
|
||||
$this->_query("commit", $connection);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -73,16 +72,11 @@
|
|||
* object if a row is returned \n
|
||||
* return\n
|
||||
**/
|
||||
function _query($query) {
|
||||
if(!$this->isConnected()) return;
|
||||
// Notify to start a query execution
|
||||
$this->actStart($query);
|
||||
function __query($query, $connection) {
|
||||
// Run the query statement
|
||||
$result = @mysql_query($query, $this->fd);
|
||||
$result = @mysql_query($query, $connection);
|
||||
// Error Check
|
||||
if(mysql_error($this->fd)) $this->setError(mysql_errno($this->fd), mysql_error($this->fd));
|
||||
// Notify to complete a query execution
|
||||
$this->actFinish();
|
||||
if(mysql_error($connection)) $this->setError(mysql_errno($connection), mysql_error($connection));
|
||||
// Return result
|
||||
return $result;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue