当前位置: 首页>>代码示例>>PHP>>正文


PHP R::rollback方法代码示例

本文整理汇总了PHP中R::rollback方法的典型用法代码示例。如果您正苦于以下问题:PHP R::rollback方法的具体用法?PHP R::rollback怎么用?PHP R::rollback使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在R的用法示例。


在下文中一共展示了R::rollback方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: edit_post

 function edit_post($f3)
 {
     // Update Tool Locations
     $this->D->sharedLocationsList = array();
     if ($f3->exists('POST.locations')) {
         foreach ($f3->get('POST.locations') as $id) {
             $this->D->sharedLocationsList[] = \R::load('locations', $id);
         }
     }
     $f3->clear('POST.locations');
     $this->D->import($f3->get('POST'));
     $this->D->training_levels or $this->D->training_levels = json_encode($f3->get('TRAINING_LEVELS'));
     \R::begin();
     try {
         $id = \R::store($this->D);
         \R::commit();
     } catch (\Exception $e) {
         \R::rollback();
         if ($e->getSQLState() == 23000) {
         }
         throw new \Exception($this->D->name . ' is not a unique name.');
         throw new \Exception();
     }
     if ($f3->get('dry')) {
         logger($f3, 'added    ' . $this->class_name() . ', id=' . $id);
     } else {
         logger($f3, 'modified ' . $this->class_name() . ', id=' . $id);
     }
     $f3->reroute($this->redirect());
 }
开发者ID:neyre,项目名称:tools.olin.edu,代码行数:30,代码来源:tools.php

示例2: save

 public function save()
 {
     $rules = array('customer_id' => 'required|', 'payment_amount' => 'required|numeric', 'payment_memo' => 'required');
     $filters = array('payment_memo' => 'trim|sanitize_string', 'payment_amount' => 'trim|sanitize_string|numeric', 'customer_id' => 'trim|numeric');
     $postValues = $gump->filter($this->{$postarray}, $filters);
     $validated = $gump->validate($gump->filter($postValues, $filters), $rules);
     $this->payment_amount = $postValues['payment_amount'];
     $this->payment_memo = $postValues['payment_memo'];
     $this->who_is_getting_paid = $postValues['customer_id'];
     if ($validated === TRUE) {
         R::begin();
         try {
             /*Payment Add*/
             $payment = R::findOne('user', ' id = ? and created_by=? ', array($this->who_is_getting_paid, $this->who_is_paying));
             $current_balance = $payment->balance2;
             $reseller_balance = R::dispense("reseller_balance");
             $reseller_balance->user_id = $this->who_is_getting_paid;
             $reseller_balance->amount = $this->{$payment_amount};
             $reseller_balance->load_by = $this->who_is_paying;
             $reseller_balance->note = $this->comments;
             $reseller_balance->ip = $_SERVER["REMOTE_ADDR"];
             $reseller_balance->updated = CURRENT_DTT;
             if ($this->payment_type == "add") {
                 $payment->balance2 = $payment->balance2 + $this->payment_amount;
                 $payment->return_payment = 0;
                 //add
                 R::exec("CALL preparestatement({$this->who_is_paying},{$this->payment_amount},{$current_balance},{$this->who_is_getting_paid},'debit','{$this->payment_memo}')");
             } elseif ($this->payment_type == "return") {
                 $payment->balance2 = $payment->balance2 - $this->payment_amount;
                 $payment->return_payment = 1;
                 //return
                 R::exec("CALL preparestatement({$this->who_is_paying},{$this->payment_amount},{$current_balance},{$this->who_is_getting_paid},'credit','{$this->payment_memo}')");
             }
             R::save($payment);
             R::save($reseller_balance);
             R::commit();
         } catch (Exception $e) {
             R::rollback();
             $this->setError("" . $e->getMessage());
         }
     } else {
         $this->setError($gump->get_readable_errors(true));
     }
     if ($this->getError() == "") {
         $this->fails = FALSE;
     } else {
         $this->fails = TRUE;
     }
 }
开发者ID:bogiesoft,项目名称:Slim_PHP_Project,代码行数:49,代码来源:payment_library.php

示例3: removeChild

 public static function removeChild($table, $parentBean, $bean)
 {
     //we still need 2 separate queries because the parent's left_id can't be updated...
     R::begin();
     try {
         R::trash($bean);
         R::exec('UPDATE ' . $table . ' SET left_id = left_id-2 WHERE left_id > ?', array($bean->right_id));
         R::exec('UPDATE ' . $table . ' SET right_id = right_id-2 WHERE right_id >= ?', array($bean->right_id));
         $parentBean->right_id -= 2;
         R::commit();
     } catch (Exception $e) {
         R::rollback();
         throw $e;
     }
 }
开发者ID:quintenvk,项目名称:quintenvk,代码行数:15,代码来源:RedBeanHelper.php

示例4: save

 public function save()
 {
     $this->amount = abs($this->amount);
     if ($this->phone == "") {
         $this->setError("Please Give number");
     } elseif (strlen($this->phone) < 11) {
         $this->setError("Phone number must be 11 digit");
     } elseif ($this->amount < 10 || $this->amount > 1000) {
         $this->setError("Amount not valid");
     } elseif ($this->restrictDublicateLoad($this->phone) == 1) {
         $this->setError("You can not request same number within 15 minute.");
     } else {
         R::begin();
         try {
             foreach ($this->cut_balance_from_id as $boss_id) {
                 $current_balance = L::getBalance($boss_id, "flexiload");
                 if ($current_balance < $this->amount) {
                     $this->setError("You do not have sufficient amount in your account");
                 } else {
                     R::exec("UPDATE user  SET {$this->balance_field}={$this->balance_field}-{$this->amount} where id='{$boss_id}'");
                     R::exec("CALL preparestatement({$boss_id},{$this->amount},{$current_balance},{$this->user_id},'credit','{$this->comments}')");
                 }
             }
             $flexiload = R::dispense("flexiload");
             $flexiload->phone = $this->phone;
             $flexiload->balance = $this->amount;
             $flexiload->load_type = $this->type;
             $flexiload->user_id = $this->user_id;
             $flexiload->s_date = CURRENT_DT;
             $flexiload->status = 'pending';
             $flexiload->s_time = time();
             $flexiload->submitted_date = CURRENT_DTT;
             $flexiload->operator = $this->getOperatorName($this->phone);
             R::store($flexiload);
             R::commit();
         } catch (Exception $e) {
             R::rollback();
             $this->setError("" . $e->getMessage());
         }
     }
     if ($this->getError() == "") {
         $this->fails = FALSE;
     } else {
         $this->fails = TRUE;
     }
 }
开发者ID:bogiesoft,项目名称:Slim_PHP_Project,代码行数:46,代码来源:flexiload_library.php

示例5: foreach

    foreach ($people_array as $people) {
        $person_old = R::getCell(' SELECT id ' . '   FROM supportsr.esr_frequent_people ' . '  WHERE name = :name ' . '    AND paper_number = :p_number ', [':name' => $people->pname, ':p_number' => $people->pidval]);
        if (empty($person_old) || $person_old == "") {
            $person_new = R::getRedBean()->dispense('esr_frequent_people');
            $person_new->name = $people->pname;
            $person_new->paper_type = $people->ptype == '身份证' ? '身份证/Id card' : ($people->ptype == '台胞证' ? '台胞证/Efficiency certificate' : ($people->ptype == '护照' ? '护照/Passport' : ($people->ptype == '港澳通行证' ? '港澳通行证/Hong Kong-Macau passport' : ($people->ptype == '驾驶证' ? '驾驶证/Driving license' : ''))));
            $person_new->paper_number = $people->pidval;
            $person_new->comid = $user['organizationname'] . '|*|' . $user['userorganizationid'];
            $person_new_id = R::store($person_new);
        }
    }
    R::commit();
} catch (Exception $e) {
    header('Content-type:text/json;charset=utf-8');
    echo json_encode(['result' => 'failed', 'error' => 'db error kayako', 'details' => $e->getMessage()]);
    R::rollback();
    die;
}
R::close();
// Precalc date value
$days_as_date = [];
foreach ($day_array as $date) {
    array_push($days_as_date, strtotime($date));
}
asort($days_as_date);
$start_date_to_post = reset($days_as_date);
$end_date_to_post = end($days_as_date);
_log(json_encode(['days_as_date' => $days_as_date]));
// Precalc equip value
$equip_datas = [];
foreach ($equip_array as $equip) {
开发者ID:adexbn,项目名称:gds_wechat,代码行数:31,代码来源:request_create_equip_in.php

示例6: create_record

 function create_record($f3, $user, $instructor, $timestamp = false)
 {
     // Create Training Record
     $training = \R::dispense('trainings');
     $training->users = $user;
     $training->tools = $this->D;
     $training->instructor = $instructor;
     $training->timestamp = $timestamp !== false ? $timestamp : time();
     $training->level = $f3->get('POST.level');
     $this->D->verify_training_level($f3->get('POST.level'));
     // Store Training Record
     \R::begin();
     try {
         $id = \R::store($training);
         \R::commit();
         $f3->set('message', $user->displayname . ' has been trained!');
         $f3->set('success', 1);
     } catch (\Exception $e) {
         \R::rollback();
         $f3->set('message', $user->displayname . ' is already trained on this machine at this level. No training record added.');
         $f3->set('success', 0);
     }
     if ($f3->get('success')) {
         logger($f3, 'added    ' . $this->class_name() . ', id=' . $id);
     }
 }
开发者ID:neyre,项目名称:tools.olin.edu,代码行数:26,代码来源:trainings.php

示例7: commitBean

 /**
  * commit a bean with transactions
  * @param object $bean
  * @return $res false or last insert id 
  */
 public static function commitBean($bean)
 {
     R::begin();
     try {
         $res = R::store($bean);
         R::commit();
     } catch (Exception $e) {
         R::rollback();
         $res = false;
     }
     return $res;
 }
开发者ID:gpawlik,项目名称:suited-php-classes,代码行数:17,代码来源:rb.php

示例8: rollback_tx

 public function rollback_tx()
 {
     \R::rollback();
 }
开发者ID:StudsPro,项目名称:island-peeps-2.0,代码行数:4,代码来源:DB.php

示例9: helAction

 /**
  * /event/user/halv
  */
 public function helAction()
 {
     $this->checkAccess();
     $eDb = new eDb();
     $halv = $eDb->getUserHalvFromUserId(session::getUserId());
     if (empty($halv)) {
         http::locationHeader('/event/user/index', 'Du skal være del af en halv kvadrille for at oprette en hel');
     }
     http::prg();
     if (isset($_POST['send'])) {
         $this->validateHel();
         if (empty($this->errors)) {
             // Prepare
             $ary = db::prepareToPostArray(array('halv'), true);
             R::begin();
             // Delete other hele
             $eDb->deleteHelFromUserId(session::getUserId());
             // Create
             $id = $eDb->createHel($ary);
             // Set a better name
             $name = $eDb->getUsersStrFromHel($id);
             $bean = rb::getBean('hel', 'id', $id);
             $bean->name = $name;
             R::store($bean);
             $res = R::commit();
             if (!$res) {
                 R::rollback();
             }
             http::locationHeader('/event/user/index');
         } else {
             echo html::getErrors($this->errors);
         }
     }
     echo $this->formCreateHel();
 }
开发者ID:diversen,项目名称:event,代码行数:38,代码来源:module.php

示例10: testTransactions

 /**
  * Test Transactions.
  * 
  * @return void
  */
 public function testTransactions()
 {
     testpack('transactions');
     R::begin();
     $bean = R::dispense('bean');
     R::store($bean);
     R::commit();
     asrt(R::count('bean'), 1);
     R::wipe('bean');
     R::freeze(1);
     R::begin();
     $bean = R::dispense('bean');
     R::store($bean);
     R::rollback();
     asrt(R::count('bean'), 0);
     R::freeze(FALSE);
     testpack('genSlots');
     asrt(R::genSlots(array('a', 'b')), '?,?');
     asrt(R::genSlots(array('a')), '?');
     asrt(R::genSlots(array()), '');
 }
开发者ID:daviddeutsch,项目名称:redbean-adaptive,代码行数:26,代码来源:Misc.php

示例11: error

function error($message)
{
    R::rollback();
    exit($message);
}
开发者ID:arshadalisoomro,项目名称:OpenSourceBikeShare,代码行数:5,代码来源:common.php

示例12: testWithWithConditionQueryBuilder

 /**
  * Test with plus query builder.
  * 
  * @return void
  */
 public function testWithWithConditionQueryBuilder()
 {
     testpack('Test with- and withCondition with Query Builder');
     $book = R::dispense('book');
     $page = R::dispense('page');
     $page->num = 1;
     $book->ownPage[] = $page;
     $page = R::dispense('page');
     $page->num = 2;
     $book->ownPage[] = $page;
     $id = R::store($book);
     $book = R::load('book', $id);
     asrt(count($book->ownPage), 2);
     $book = R::load('book', $id);
     asrt(count($book->withCondition(' num >  1')->ownPage), 1);
     $book = R::load('book', $id);
     asrt(count($book->withCondition(R::$f->begin()->num(' < ?')->put(2))->ownPage), 1);
     $book = R::load('book', $id);
     asrt(count($book->with(R::$f->begin()->limit(' 1 '))->ownPage), 1);
     $book = R::load('book', $id);
     asrt(count($book->withCondition(R::$f->begin()->num(' < 3'))->ownPage), 2);
     $book = R::load('book', $id);
     asrt(count($book->with(R::$f->begin()->limit(' 2 '))->ownPage), 2);
     testpack('Transaction suppr. in fluid mode');
     R::freeze(FALSE);
     asrt(R::begin(), FALSE);
     asrt(R::commit(), FALSE);
     asrt(R::rollback(), FALSE);
     R::freeze(TRUE);
     asrt(R::begin(), TRUE);
     asrt(R::commit(), TRUE);
     R::freeze(FALSE);
 }
开发者ID:daviddeutsch,项目名称:redbean-adaptive,代码行数:38,代码来源:Misc.php


注:本文中的R::rollback方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。