[eluser]Unknown[/eluser]
trans_start() method from the DB_driver.php (CodeIgniter 1.7.1)
Code:
function trans_start($test_mode = FALSE)
{
if ( ! $this->trans_enabled)
{
return FALSE;
}
// When transactions are nested we only begin/commit/rollback the outermost ones
if ($this->_trans_depth > 0)
{
$this->_trans_depth += 1;
return;
}
$this->trans_begin($test_mode);
}
trans_complete() method from the DB_driver.php (CodeIgniter 1.7.1)
Code:
function trans_complete()
{
if ( ! $this->trans_enabled)
{
return FALSE;
}
// When transactions are nested we only begin/commit/rollback the outermost ones
if ($this->_trans_depth > 1)
{
$this->_trans_depth -= 1;
return TRUE;
}
// The query() function will set this flag to FALSE in the event that a query failed
if ($this->_trans_status === FALSE)
{
$this->trans_rollback();
// If we are NOT running in strict mode, we will reset
// the _trans_status flag so that subsequent groups of transactions
// will be permitted.
if ($this->trans_strict === FALSE)
{
$this->_trans_status = TRUE;
}
log_message('debug', 'DB Transaction Failure');
return FALSE;
}
$this->trans_commit();
return TRUE;
}
trans_complete() method from the DB_driver.php (CodeIgniter 1.7.1)
Following code is a part of trans_begin, trans_commit, trans_rollback from mysql_driver.php(same with other driver files) (CodeIgniter 1.7.1)
Code:
if ($this->_trans_depth > 0)
{
return TRUE;
}
so... if you want to use mutiple transactions.
you should modify trans_start() method and trans_complete() method from DB_driver.php
it should be
Code:
function trans_start($test_mode = FALSE)
{
if ( ! $this->trans_enabled)
{
return FALSE;
}
// When transactions are nested we only begin/commit/rollback the outermost ones
if ($this->_trans_depth > 0)
{
$this->_trans_depth += 1;
return;
}
$this->trans_begin($test_mode);
$this->_trans_depth += 1;
}
function trans_complete()
{
if ( ! $this->trans_enabled)
{
return FALSE;
}
// When transactions are nested we only begin/commit/rollback the outermost ones
if ($this->_trans_depth > 1)
{
$this->_trans_depth -= 1;
return TRUE;
}elseif($this->_trans_depth==1){
$this->_trans_depth -= 1;
}
// The query() function will set this flag to FALSE in the event that a query failed
if ($this->_trans_status === FALSE)
{
$this->trans_rollback();
// If we are NOT running in strict mode, we will reset
// the _trans_status flag so that subsequent groups of transactions
// will be permitted.
if ($this->trans_strict === FALSE)
{
$this->_trans_status = TRUE;
}
log_message('debug', 'DB Transaction Failure');
return FALSE;
}
$this->trans_commit();
return TRUE;
}
and you can use it
Code:
$this->db->trans_start();
$this->db->trans_start();
....
$this->db->trans_complete();
$this->db->trans_start();
....
$this->db->trans_complete();
$this->db->trans_complete();