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


PHP Transaction::commit方法代码示例

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


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

示例1: registerNewUser

 /**
  * @param User $user
  * @param Invitation $invitation
  * @return void
  * @throws Runtime\DuplicateUsernameException
  * @throws Runtime\DuplicateEmailException
  * @throws Runtime\InvitationNotFoundException
  * @throws Runtime\InvitationExpiredException
  * @throws Runtime\InvitationTokenMatchException
  * @throws \DibiException
  */
 public function registerNewUser(User $user, Invitation $invitation)
 {
     if (!$user->isDetached()) {
         throw new InvalidArgumentException('Only detached instances of Entity ' . User::class . ' can pass.');
     }
     $this->checkInvitation($user->email, $invitation->token);
     try {
         $this->transaction->begin();
         $this->userRepository->persist($user);
         $this->removeInvitation($invitation);
         $this->transaction->commit();
     } catch (\DibiException $e) {
         if ($e->getCode() == 1062) {
             try {
                 $this->userRepository->checkUsername($user->username);
             } catch (Runtime\UserAlreadyExistsException $usernameException) {
                 $this->transaction->rollback();
                 throw new Runtime\DuplicateUsernameException();
             }
             try {
                 $this->userRepository->checkEmail($user->email);
             } catch (Runtime\UserAlreadyExistsException $emailException) {
                 $this->transaction->rollback();
                 throw new Runtime\DuplicateEmailException();
             }
         }
         $this->transaction->rollback();
         Debugger::log($e, Debugger::ERROR);
         throw $e;
     }
 }
开发者ID:blitzik,项目名称:vycetky,代码行数:42,代码来源:UserManager.php

示例2: changeType

 /**
  * Override BundlableLabelableBaseModelWithAttributes::changeType() to update
  * current location "subclass" (ie. type) value when type change is used.
  * This should be invoked by any model that can be used to indicate object
  * storage location. This includes, for now at least, ca_loans, ca_movements, 
  * ca_occurrences and ca_objects_x_storage_locations.
  *
  * @param mixed $pm_type The type_id or code to change the current type to
  * @return bool True if change succeeded, false if error
  */
 public function changeType($pm_type)
 {
     if (!$this->getPrimaryKey()) {
         return false;
     }
     // row must be loaded
     if (!($vb_already_in_transaction = $this->inTransaction())) {
         $this->setTransaction($o_t = new Transaction($this->getDb()));
     }
     if ($vn_rc = parent::changeType($pm_type)) {
         $o_db = $this->getDb();
         $o_db->query("\n\t\t\t\t\tUPDATE ca_objects SET current_loc_subclass = ? \n\t\t\t\t\tWHERE \n\t\t\t\t\t\tcurrent_loc_class = ? AND current_loc_id = ?\n\t\t\t\t", array($this->get('type_id'), $this->tableNum(), $this->getPrimaryKey()));
         if ($o_db->numErrors()) {
             $this->errors = $o_db->errors;
             if (!$vb_already_in_transaction) {
                 $o_t->rollback();
             }
             return false;
         }
     }
     if (!$vb_already_in_transaction) {
         $o_t->commit();
     }
     return $vn_rc;
 }
开发者ID:idiscussforum,项目名称:providence,代码行数:35,代码来源:BaseObjectLocationModel.php

示例3: saveListingItem

 /**
  * @param ListingItem $listingItem
  * @return ListingItem
  * @throws ListingItemDayAlreadyExistsException
  * @throws \DibiException
  */
 public function saveListingItem(ListingItem $listingItem)
 {
     try {
         $this->transaction->begin();
         $this->listingItemRepository->persist($listingItem);
         $this->localityRepository->saveLocalityToUserList($listingItem->locality, $listingItem->listing->getRowData()['userID']);
         $this->transaction->commit();
         return $listingItem;
     } catch (\DibiException $e) {
         $this->transaction->rollback();
         if ($e->getCode() == 1062) {
             throw new ListingItemDayAlreadyExistsException();
         }
         Debugger::log($e, Debugger::ERROR);
         throw $e;
     }
 }
开发者ID:blitzik,项目名称:vycetky,代码行数:23,代码来源:ItemFacade.php

示例4: commit

 public function commit()
 {
     $atomDao = new BaseDao("CertifierTransactionAtom");
     $atom = $atomDao->getPattern();
     $atom->transFid = $this->getId();
     $list = $atomDao->search($atom);
     foreach ($list as $element) {
         $element->delete();
     }
     parent::commit();
 }
开发者ID:bobah,项目名称:acbdb,代码行数:11,代码来源:CertifierTransaction.class.php

示例5: 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

示例6: deleteWidget

function deleteWidget($id)
{
    try {
        $transaction = new Transaction();
        $result = DAOFactory::getAfiliadoWidgetDAO()->delete($id);
        $transaction->commit();
        return $result;
    } catch (Exception $e) {
        print_r($e);
        if ($transaction) {
            $transaction->rollback();
        }
        return false;
    }
}
开发者ID:randyibarrola,项目名称:active,代码行数:15,代码来源:widget.php

示例7: insertBusquedaDisponibilidad

function insertBusquedaDisponibilidad($data)
{
    try {
        $transaction = new Transaction();
        $busqueda = DAOFactory::getBusquedaDisponibilidadDAO()->prepare($data);
        $id = DAOFactory::getBusquedaDisponibilidadDAO()->insert($busqueda);
        $transaction->commit();
        return $id;
    } catch (Exception $e) {
        var_dump($e);
        if ($transaction) {
            $transaction->rollback();
        }
        return false;
    }
}
开发者ID:randyibarrola,项目名称:active,代码行数:16,代码来源:busqueda.php

示例8: deleteFaq

function deleteFaq($id)
{
    try {
        $transaction = new Transaction();
        $faq = DAOFactory::getFaqDAO()->load($id);
        DAOFactory::getFaqDAO()->delete($id);
        $transaction->commit();
        return true;
    } catch (Exception $e) {
        var_dump($e);
        if ($transaction) {
            $transaction->rollback();
        }
        return false;
    }
}
开发者ID:randyibarrola,项目名称:active,代码行数:16,代码来源:faq.php

示例9: sendMessages

 /**
  * @param array $messages Key => recipientID, Value = Message entity or array of messages
  * @throws InvalidArgumentException
  * @throws \DibiException
  * @return array
  */
 public function sendMessages(array $messages)
 {
     $ex = new InvalidArgumentException('Only non-persisted instances of ' . Message::class . ' can pas.');
     $msgs = [];
     foreach ($messages as $recipientID => $recipientMessages) {
         Validators::assert($recipientID, 'numericint');
         if (is_array($recipientMessages)) {
             foreach ($recipientMessages as $message) {
                 if (!($message instanceof Message and $message->isDetached())) {
                     throw $ex;
                 }
                 $msgs[] = $message;
             }
         } else {
             // recipientMessages contains only one message
             if (!($recipientMessages instanceof Message and $recipientMessages->isDetached())) {
                 throw $ex;
             }
             $msgs[] = $recipientMessages;
         }
     }
     try {
         $this->transaction->begin();
         $this->messageRepository->saveMessages($msgs);
         unset($msgs);
         $usersMessages = [];
         foreach ($messages as $recipientID => $recipientMessages) {
             if (is_array($recipientMessages)) {
                 foreach ($recipientMessages as $message) {
                     $recipientMessage = new UserMessage($message, $recipientID);
                     $usersMessages[] = $recipientMessage;
                 }
             } else {
                 $recipientMessage = new UserMessage($recipientMessages, $recipientID);
                 $usersMessages[] = $recipientMessage;
             }
         }
         $this->userMessageRepository->sendMessagesToRecipients($usersMessages);
         $this->transaction->commit();
         return $usersMessages;
     } catch (\DibiException $e) {
         $this->transaction->rollback();
         Debugger::log($e, Debugger::ERROR);
         throw $e;
     }
 }
开发者ID:blitzik,项目名称:vycetky,代码行数:52,代码来源:MessagesFacade.php

示例10: commit

 public function commit($auth = NULL)
 {
     $args = func_get_args();
     if ($auth != Transaction::SIGNATURE) {
         return Transaction::commit();
     }
     if (!$this->txn) {
         return FALSE;
     }
     if ($this->lock) {
         return FALSE;
     }
     $res = (bool) $this->__call(__FUNCTION__, array());
     if (!$res) {
         return $res;
     }
     $this->txn = FALSE;
     return $res;
 }
开发者ID:Gaia-Interactive,项目名称:gaia_core_php,代码行数:19,代码来源:callback.php

示例11: deleteCondicion

function deleteCondicion($id, $transactional = true)
{
    try {
        if ($transactional) {
            $transaction = new Transaction();
        }
        DAOFactory::getHotelCondicionDAO()->deleteByCondicionId($id);
        DAOFactory::getCondicionDAO()->delete($id);
        if ($transactional) {
            $transaction->commit();
        }
        return $id;
    } catch (Exception $e) {
        var_dump($e);
        if ($transactional && $transaction) {
            $transaction->rollback();
        }
        return false;
    }
}
开发者ID:randyibarrola,项目名称:active,代码行数:20,代码来源:condiciones.php

示例12: 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

示例13: action_update

 public function action_update(Params $param)
 {
     $this->content->bind('form', $torn);
     $project = Jelly::select('project')->link($param->id)->load();
     if (!$project->loaded()) {
         throw new Error404_Exception();
     }
     $torn = new Torn($project);
     if ($torn->check()) {
         try {
             Transaction::begin();
             $project->set($_FILES + $_POST);
             $project->save();
             Transaction::commit();
             $this->request->redirect(Route::get('protected')->uri(array('controller' => 'project')));
         } catch (Validate_Exception $e) {
             Transaction::rollback();
             $torn->catch_errors($e);
         }
     }
 }
开发者ID:TdroL,项目名称:piotrszkaluba.pl,代码行数:21,代码来源:project.php

示例14: updateFactura

function updateFactura($id, $data = array(), $trasactional = true)
{
    try {
        if ($trasactional) {
            $transaction = new Transaction();
        }
        $factura = getFactura($id);
        $factura = DAOFactory::getFacturaDAO()->prepare($data, $id);
        DAOFactory::getFacturaDAO()->update($factura);
        if ($trasactional) {
            $transaction->commit();
        }
        return true;
    } catch (Exception $e) {
        var_dump($e);
        if ($transaction) {
            $transaction->rollback();
        }
        return false;
    }
}
开发者ID:randyibarrola,项目名称:active,代码行数:21,代码来源:factura.php

示例15: updatePromocionPalabrasClave

function updatePromocionPalabrasClave($id, $data = array(), $data_hoteles = array())
{
    try {
        $transaction = new Transaction();
        $promocion = DAOFactory::getPromocionPalabrasClavesDAO()->prepare($data, $id);
        DAOFactory::getPromocionPalabrasClavesDAO()->update($promocion);
        DAOFactory::getPromocionPalabrasClavesHotelDAO()->deleteByPromocionId($id);
        if ($data_hoteles && is_array($data_hoteles) && count($data_hoteles)) {
            foreach ($data_hoteles as $hid) {
                $hotel_promo = DAOFactory::getPromocionPalabrasClavesHotelDAO()->prepare(array('promocionId' => $id, 'hotelId' => $hid));
                DAOFactory::getPromocionPalabrasClavesHotelDAO()->insert($hotel_promo);
            }
        }
        $transaction->commit();
        return true;
    } catch (Exception $e) {
        error_log($e);
        if ($transaction) {
            $transaction->rollback();
        }
        return false;
    }
}
开发者ID:randyibarrola,项目名称:active,代码行数:23,代码来源:promocion.php


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