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


PHP Manager::transaction方法代码示例

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


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

示例1: updateRadius

 public function updateRadius()
 {
     Capsule::transaction(function () {
         Capsule::table('radcheck')->where('username', $this->user)->delete();
         Capsule::table('radreply')->where('username', $this->user)->delete();
         Capsule::table('radcheck')->insert($this->check);
         Capsule::table('radreply')->insert($this->reply);
     });
 }
开发者ID:ithoq,项目名称:am-radius,代码行数:9,代码来源:Authorize.php

示例2: store

 public function store()
 {
     $seven_days = 60 * 60 * 24 * 7;
     $two_hours = 60 * 60 * 2;
     $season = $_REQUEST['season'];
     $venue_id = $_REQUEST['venue_id'];
     $activity = $_REQUEST['activity'];
     $lastSeasonsLeague = League::where('season', $season - 1)->where('venue_id', $venue_id)->where('activity', $activity)->first();
     $lastSeasonsLastGame = Event::where('league_id', $lastSeasonsLeague->id)->where('week_num', 'Wild Card')->where('game_num', 1)->first();
     $start_dt = $_REQUEST['start_dt'];
     $start_dt = $start_dt ? strtotime($start_dt) : strtotime($lastSeasonsLastGame->date) + $seven_days;
     $start_wk = $_REQUEST['start_wk'];
     $start_wk -= 1;
     $week_cnt = $_REQUEST['week_cnt'];
     $game_cnt = $_REQUEST['game_cnt'];
     $games_tm = $_REQUEST['games_tm'];
     $games_tm = $games_tm ? strtotime($games_tm) : strtotime($lastSeasonsLastGame->time);
     $events = [];
     for ($i = $start_wk; $i <= $week_cnt; $i++) {
         $week_num = $i == $week_cnt ? 'Wild Card' : $i + 1;
         for ($j = 0; $j < $game_cnt; $j++) {
             $datetime = date('Y-m-d', $start_dt + $seven_days * $i) . ' ' . date('H:i:s', $games_tm + $two_hours * $j);
             $game_num = $j + 1;
             $league = League::where('season', $season)->where('venue_id', $venue_id)->where('activity', $activity)->first();
             if (!$league) {
                 $league = new League();
                 $league->season = $season;
                 $league->venue_id = $venue_id;
                 $league->activity = $activity;
                 $league->save();
             }
             $event = new Event();
             $event->league_id = $league->id;
             $event->season = $league->season;
             $event->venue_id = $league->venue_id;
             $event->datetime = $datetime;
             $event->week_num = $week_num;
             $event->game_num = $game_num;
             $event->activity = $league->activity;
             $events[] = $event;
         }
     }
     try {
         DB::transaction(function () use($events) {
             foreach ($events as $event) {
                 $event->save();
             }
         });
         $_SESSION['ALERT'] = alert('Season Added!', "Season {$season} for " . Venue::find($venue_id)->name . " was created successfully.", 'success');
     } catch (Excepton $e) {
         print_r($e);
         exit;
         $_SESSION['ALERT'] = alert('Season Not Added!', "Season {$season} for " . Venue::find($venue_id)->name . " could not be created.", 'error');
     }
     return redirect('/seasons');
 }
开发者ID:MadeByGlutard,项目名称:GreenMountainGaming.com,代码行数:56,代码来源:SeasonsController.php

示例3: migrate

 public function migrate()
 {
     DB::transaction(function () {
         $this->createCategoriesTable();
         $this->createTypesTable();
         $this->createDealsTable();
         $this->createDealsCategoriesTable();
         $this->createDealsTypesTable();
         $this->createMerchantsTable();
         $this->createNetworksTable();
     });
 }
开发者ID:FMTCco,项目名称:fmtc-php,代码行数:12,代码来源:Migration.php

示例4: dbTrans

 /**
  * Execute a database transaction
  *
  * @param callable $callback
  * @param callable $errorCallback (optional)
  * @return mixed
  */
 protected function dbTrans(callable $callback, callable $errorCallback = null, array $errorContext = null)
 {
     try {
         return DB::transaction($callback);
     } catch (\Exception $e) {
         Log::log(LogLevel::ERROR, $e->getMessage(), $errorContext);
         if (!empty($errorCallback)) {
             $errorCallback($e);
         } else {
             throw $e;
         }
     }
 }
开发者ID:bonaccorsop,项目名称:JambonOrders,代码行数:20,代码来源:DbTrait.php

示例5: create

 /**
  * Index route for getting all Emojis.
  *
  * @param ServerRequestInterface ServerRequestInterface $request  PSR-7 standard for receiving client request
  * @param ResponseInterface      ResponseInterface      $response PSR-& standard for sending server response
  *
  * @return ResponseInterface HTTP response of client request
  */
 public function create(ServerRequestInterface $request, ResponseInterface $response)
 {
     //Get Emoji data from request
     $data = $request->getParsedBody();
     //Extract keywords from data
     $keywords = $data['keywords'];
     //Decode token to get object of data
     $decodedToken = Auth::decodeToken($request->getHeader('Authorization')[0], $request);
     //Check if user exist with the user id
     $user = User::find($decodedToken->data->uid);
     //Generate emoji data to return
     $emoji = ['name' => $data['name'], 'char' => $data['char'], 'category' => $data['category']];
     DB::transaction(function () use($user, $emoji, $keywords) {
         //Insert Emoji data into emojis table
         $emoji = $user->emojis()->create($emoji);
         $keywordsObj = [];
         //create emoji keyword objects
         foreach ($keywords as $keyword) {
             $obj = new EmojiKeyword();
             $obj->name = $keyword;
             $keywordsObj[] = $obj;
         }
         //Save all keywords objects
         $emoji->keywords()->saveMany($keywordsObj);
     });
     $response->getBody()->write(json_encode(['message' => 'Emoji created']));
     return $response;
 }
开发者ID:andela-gjames,项目名称:Emoji-API,代码行数:36,代码来源:EmojiController.php


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