function _end_transaction()
 {
     if (!$this->is_transaction_required()) {
         return;
     }
     if ($this->_response->is_success()) {
         commit_user_transaction();
     } else {
         rollback_user_transaction();
     }
 }
  function _end_transaction(&$request)
  {
    if(!$this->is_transaction_required())
      return;

    if($request->is_success())
      commit_user_transaction();
    else
      rollback_user_transaction();
  }
function reload_popup($url = PHP_SELF)
{
    if (!isset($_REQUEST['popup']) || !$_REQUEST['popup']) {
        return;
    }
    ob_end_clean();
    ob_start();
    echo "<html><body><script>\r\n\t\t\t\t\t\t\tif(window.opener)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\thref = window.opener.location.href;";
    echo _add_js_random_to_url('href');
    echo " window.opener.location.href = href;";
    echo "\t\r\n\t\t\t\t\t\t\t\twindow.opener.focus();\r\n\t\t\t\t\t\t\t}";
    echo "href = '{$url}';";
    echo _add_js_random_to_url('href');
    echo "window.location.href = href;";
    echo '</script>
					</body>
				</html>';
    ob_end_flush();
    commit_user_transaction();
    exit;
}
 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 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);
  }