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


PHP Transaction::execute方法代码示例

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


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

示例1: drop

 public function drop($playerId)
 {
     $t = new Transaction();
     // Award any outstanding match to the opposing player.
     $sql = 'SELECT match_id ' . 'FROM player_match ' . 'WHERE wins IS NULL AND player_id = ' . Q($playerId);
     $matchId = D()->value($sql, null);
     if ($matchId !== null) {
         $sql = 'UPDATE player_match ' . 'SET wins = 0 ' . 'WHERE match_id = ' . Q($matchId) . ' AND player_id = ' . Q($playerId);
         $t->execute($sql);
         $sql = 'UPDATE player_match ' . 'SET wins = 1 ' . 'WHERE match_id = ' . Q($matchId) . ' AND player_id <> ' . Q($playerId);
         $t->execute($sql);
     }
     // Drop player from any unstarted events.
     $sql = 'DELETE pe ' . 'FROM player_event AS pe ' . 'INNER JOIN event AS e ON pe.event_id = e.id ' . 'WHERE NOT started AND player_id = ' . Q($playerId);
     $t->execute($sql);
     // Drop player from any started events.
     $sql = 'UPDATE player_event ' . 'SET dropped = TRUE ' . 'WHERE player_id = ' . Q($playerId) . ' AND event_id IN (SELECT event_id FROM event WHERE NOT finished)';
     $t->execute($sql);
     return $t->commit();
 }
开发者ID:jthemphill,项目名称:tournament,代码行数:20,代码来源:events.php

示例2: report

 public function report($wins, $opponentWins)
 {
     if (!$this->awaitingResult()) {
         $msg = 'Tried to report when not awaiting result.';
         throw new IllegalStateException($msg);
     }
     $t = new Transaction();
     $entries = [$this->playerId => $wins, $this->opponentId => $opponentWins];
     foreach ($entries as $playerId => $playerWins) {
         $sql = 'UPDATE player_match SET wins = ' . Q($playerWins) . ' WHERE match_id = ' . Q($this->matchId) . ' AND player_id = ' . Q($playerId);
         $t->execute($sql);
     }
     $t->commit();
 }
开发者ID:jthemphill,项目名称:tournament,代码行数:14,代码来源:match.php

示例3: testCreateAndExecuteTransactionWithTransactionErrorUniqueConstraintOnSave

   /**
    * Test if we get an error back, if we violate a unique constraint
    */
   public function testCreateAndExecuteTransactionWithTransactionErrorUniqueConstraintOnSave()
   {
       if (isCluster($this->connection)) {
           // don't execute this test in a cluster
           return;
       }
       $writeCollections = array($this->collection1->getName());
       $readCollections = array($this->collection2->getName());
       $action = '
 function () {
   var db = require("internal").db;
   db.' . $this->collection1->getName() . '.save({ _key : "hello" });
   db.' . $this->collection1->getName() . '.save({ _key : "hello" });
 }';
       $transaction = new Transaction($this->connection);
       $transaction->setWriteCollections($writeCollections);
       $transaction->setReadCollections($readCollections);
       $transaction->setAction($action);
       $e = null;
       try {
           $transaction->execute();
       } catch (ServerException $e) {
       }
       $details = $e->getDetails();
       $expectedCutDownMessage = "unique constraint violated";
       $this->assertTrue($e->getCode() == 400 && strstr($details['errorMessage'], $expectedCutDownMessage) !== false, 'Did not return code 400 with first part of the message: "' . $expectedCutDownMessage . '", instead returned: ' . $e->getCode() . ' and "' . $details['errorMessage'] . '"');
   }
开发者ID:TomSearch,项目名称:arangodb-php-docs,代码行数:30,代码来源:TransactionTest.php


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