function process() { if (!$this->_current_action) { return false; } if ($is_transacton = $this->_is_transaction_required()) { start_user_transaction(); } $action =& $this->get_action_object(); $perform_result = true; if (is_object($action)) { if ($view =& $this->get_view()) { $action->set_view($view); } $perform_result = $action->perform(); } if ($is_transacton) { if ($perform_result) { commit_user_transaction(); } else { rollback_user_transaction(); } } return $perform_result; }
function _start_transaction() { if ($this->is_transaction_required()) { start_user_transaction(); } }
function test_transactions() { $db =& db_factory :: instance(); start_user_transaction(); $db->sql_insert("founding_fathers", array('first' => 'Richard', 'last' => 'Nixon', 'dog_name' => null)); $db->sql_insert("founding_fathers", array('first' => 'Richard', 'last' => 'Nixon2', 'dog_name' => null)); $db->sql_insert("founding_fathers", array('first' => 'Richard', 'last' => 'Nixon3', 'dog_name' => null)); rollback_user_transaction(); $db->sql_select("founding_fathers", '*', 'last="Nixon"'); $this->assertEqual(sizeof($db->get_array()), 0); start_user_transaction(); $db->sql_insert("founding_fathers", array('first' => 'Richard', 'last' => 'Nixon', 'dog_name' => null)); $db->sql_insert("founding_fathers", array('first' => 'Richard', 'last' => 'Nixon2', 'dog_name' => null)); $db->sql_insert("founding_fathers", array('first' => 'Richard', 'last' => 'Nixon3', 'dog_name' => null)); commit_user_transaction(); $db->sql_select("founding_fathers", '*', 'last="Nixon" OR last="Nixon2" OR last="Nixon3"'); $this->assertEqual(sizeof($db->get_array()), 3); start_user_transaction(); $db->sql_insert("founding_fathers", array('first' => 'Richard', 'last' => 'Nixxxxx', 'dog_name' => null)); $db->sql_select("founding_fathers", '*', 'last="Nixxxxx"'); $arr = $db->get_array(); $this->assertEqual(sizeof($arr), 1); $this->assertEqual($arr[0]['last'], 'Nixxxxx'); rollback_user_transaction(); $db->sql_select("founding_fathers", '*', 'last="Nixxxxx"'); $arr = $db->get_array(); $this->assertEqual(sizeof($arr), 0); }