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


PHP Database::inTransaction方法代码示例

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


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

示例1: update

 public function update()
 {
     $inTransaction = Database::inTransaction();
     if (!$inTransaction) {
         Database::beginTransaction();
     }
     $statement = Database::prepare("UPDATE user_power SET `uid`=:uid WHERE id=:id");
     $statement->bindValue(':uid', $this->uid, \PDO::PARAM_INT);
     $statement->bindValue(':id', $this->id, \PDO::PARAM_INT);
     $statement->execute();
     $this->uid = Database::lastInsertId();
     $statement->execute();
     if (!$inTransaction) {
         Database::commit();
     }
 }
开发者ID:haitao-wang,项目名称:shadowsocks-panel,代码行数:16,代码来源:UserPower.php

示例2: updateUser

 /**
  * update User info
  *
  */
 public function updateUser()
 {
     $inTransaction = Database::inTransaction();
     if (!$inTransaction) {
         Database::beginTransaction();
     }
     $statement = Database::prepare("UPDATE member SET email=:email, `password`=:pwd, sspwd=:sspwd, `port`=:port, nickname=:nickname,\n            `flow_up`=:flow_up, `flow_down`=:flow_down, transfer=:transfer, plan=:plan, `enable`=:enable, invite=:invite, regDateLine=:regDateLine WHERE uid=:userId");
     $statement->bindValue(':email', $this->email, \PDO::PARAM_STR);
     $statement->bindValue(':pwd', $this->password, \PDO::PARAM_STR);
     $statement->bindValue(':sspwd', $this->sspwd, \PDO::PARAM_STR);
     $statement->bindValue(':port', $this->port, \PDO::PARAM_INT);
     $statement->bindValue(':nickname', $this->nickname, \PDO::PARAM_STR);
     $statement->bindValue(':flow_up', $this->flow_up, \PDO::PARAM_INT);
     $statement->bindValue(':flow_down', $this->flow_down, \PDO::PARAM_INT);
     $statement->bindValue(':transfer', $this->transfer, \PDO::PARAM_INT);
     $statement->bindValue(':plan', $this->plan, \PDO::PARAM_STR);
     $statement->bindValue(':enable', $this->enable, \PDO::PARAM_INT);
     $statement->bindValue(':invite', $this->invite, \PDO::PARAM_INT);
     $statement->bindValue(':regDateLine', $this->regDateLine, \PDO::PARAM_INT);
     $statement->bindValue(':userId', $this->uid, \PDO::PARAM_INT);
     $statement->execute();
     if (!$inTransaction) {
         Database::commit();
     }
 }
开发者ID:gclove,项目名称:shadowsocks-panel,代码行数:29,代码来源:User.php

示例3: updateInvite

 public function updateInvite()
 {
     $inTransaction = Database::inTransaction();
     if (!$inTransaction) {
         Database::beginTransaction();
     }
     $statement = Database::prepare("UPDATE invite SET expiration=:expiration,\n\t\t\t`reguid`=:reguid, `regDateLine`=:regDateLine, `status`=:status, `inviteIp`=:inviteIp WHERE invite=:invite");
     $statement->bindValue(':expiration', $this->expiration, \PDO::PARAM_INT);
     $statement->bindValue(':reguid', $this->reguid, \PDO::PARAM_INT);
     $statement->bindValue(':regDateLine', $this->regDateLine, \PDO::PARAM_INT);
     $statement->bindValue(':status', $this->status, \PDO::PARAM_INT);
     $statement->bindValue(':inviteIp', $this->inviteIp, \PDO::PARAM_STR);
     $statement->bindValue(':invite', $this->invite, \PDO::PARAM_STR);
     $statement->execute();
     if (!$inTransaction) {
         Database::commit();
     }
 }
开发者ID:vacan,项目名称:shadowsocks-panel,代码行数:18,代码来源:Invite.php

示例4: savePassword

 /**
  * Save new password
  * @param string $password New password
  */
 public function savePassword($password)
 {
     $salt = substr(md5($this->id . $this->email . ENCRYPT_KEY), 8, 16);
     $this->password = substr(md5(md5($password) . $salt), 0, 30) . 'T' . self::ENCRYPT_TYPE_ENHANCE;
     $inTransaction = Database::inTransaction();
     if (!$inTransaction) {
         Database::beginTransaction();
     }
     $statement = Database::prepare("UPDATE member SET `password`=:pwd WHERE id=:userId");
     $statement->bindValue(':pwd', $this->password, \PDO::PARAM_STR);
     $statement->bindValue(':userId', $this->id, \PDO::PARAM_INT);
     $statement->execute();
     if (!$inTransaction) {
         Database::commit();
     }
 }
开发者ID:biaoiaoo,项目名称:KK-Framework,代码行数:20,代码来源:User.php

示例5: handleException

 public static function handleException($e)
 {
     if (error_reporting() == 0) {
         return;
     }
     while (ob_get_level() > 0) {
         ob_end_clean();
     }
     $eS = $e->getMessage();
     $eN = $e->getCode();
     $eC = $e->getTrace();
     // Put current context into stack trace
     array_unshift($eC, array('file' => $e->getFile(), 'line' => $e->getLine()));
     if ($e instanceof ErrorException) {
         switch ($e->getSeverity()) {
             case E_ERROR:
             case E_PARSE:
             case E_CORE_ERROR:
             case E_USER_ERROR:
             default:
                 $logType = LogLevel::CRITICAL;
                 break;
             case E_WARNING:
             case E_CORE_WARNING:
             case E_USER_WARNING:
                 $logType = LogLevel::WARNING;
                 break;
             case E_DEPRECATED:
             case E_NOTICE:
             case E_USER_DEPRECATED:
             case E_USER_NOTICE:
                 $logType = LogLevel::NOTICE;
                 break;
             case E_STRICT:
                 $logType = LogLevel::INFO;
                 break;
         }
         $exceptionType = 'error';
     } else {
         $exceptionType = get_class($e);
         if (strpos($exceptionType, '\\') !== false) {
             $exceptionType = substr(strrchr($exceptionType, '\\'), 1);
         }
         $logType = LogLevel::ERROR;
     }
     $logString = sprintf('[Gateway] Uncaught %s#%d with message: "%s".', $exceptionType, $eN, $eS);
     unset($exceptionType);
     // Current request context
     $resolver = Resolver::getActiveInstance();
     if ($resolver) {
         if ($resolver->request()) {
             $client = $resolver->request()->client();
         }
         $response = $resolver->response();
     }
     unset($resolver);
     // Prevent recursive errors on logging when database fails to connect.
     if (Database::isConnected()) {
         // Release table locks of current session.
         @Database::unlockTables(false);
         if (Database::inTransaction()) {
             @Database::rollback();
         }
     }
     $logContext = array_filter(array('errorContext' => $eC, 'client' => @$client));
     // Log the error
     try {
         @Log::log($logType, $logString, $logContext);
     } catch (\Exception $e) {
     }
     unset($logContext);
     // Send the error to output
     $output = array('error' => $eS, 'code' => $eN);
     if (System::environment(false) != System::ENV_PRODUCTION) {
         $output['trace'] = $eC;
     }
     // Display error message
     if (isset($response) && @$client['type'] != 'cli') {
         // Do i18n when repsonse context is available
         if ($e instanceof GeneralException) {
             $errorMessage = $response->__($eS, $logType);
             if ($errorMessage) {
                 $output['error'] = $errorMessage;
             }
         }
         if ($e instanceof ErrorException) {
             $statusCode = 500;
         } else {
             $statusCode = 400;
         }
         if ($e instanceof ValidationException) {
             $output['errors'] = $e->getErrors();
         }
         $response->clearHeaders();
         $response->header('Content-Type', 'application/json; charset=utf-8');
         $response->send($output, $statusCode);
     } else {
         header('Content-Type: text/plain', true, 500);
         echo "{$logString}\n";
         // Debug stack trace
//.........这里部分代码省略.........
开发者ID:Victopia,项目名称:prefw,代码行数:101,代码来源:ExceptionsHandler.php

示例6: deleteNode

 /**
  * 删除 node
  * @param $nodeId  Int
  */
 public static function deleteNode($nodeId)
 {
     $inTransaction = Database::inTransaction();
     if (!$inTransaction) {
         Database::beginTransaction();
     }
     $statement = Database::prepare("DELETE * FROM node WHERE id=:id");
     $statement->bindValue(':id', $nodeId, \PDO::PARAM_INT);
     $statement->execute();
     if (!$inTransaction) {
         Database::commit();
     }
 }
开发者ID:haitao-wang,项目名称:shadowsocks-panel,代码行数:17,代码来源:Node.php

示例7: update

 /**
  * Update message
  */
 public function update()
 {
     $inTransaction = Database::inTransaction();
     if (!$inTransaction) {
         Database::beginTransaction();
     }
     $statement = Database::prepare("UPDATE message SET `content`=:content, `pushTime`=:pushTime,\n\t\t\t`addTime`=:addTime, `pushUsers`=:pushUsers, `type`=:type, `pushEndTime`:=pushEndTime,\n\t\t\t `order`=:order WHERE id=:id");
     $statement->bindValue(':content', $this->name, \PDO::PARAM_STR);
     $statement->bindValue(':pushTime', $this->type, \PDO::PARAM_INT);
     $statement->bindValue(':addTime', $this->server, \PDO::PARAM_INT);
     $statement->bindValue(':pushUsers', $this->method, \PDO::PARAM_STR);
     $statement->bindValue(':type', $this->info, \PDO::PARAM_INT);
     $statement->bindValue(':pushEndTime', $this->status, \PDO::PARAM_INT);
     $statement->bindValue(':order', $this->order, \PDO::PARAM_INT);
     $statement->bindValue(':id', $this->order, \PDO::PARAM_INT);
     $statement->execute();
     if (!$inTransaction) {
         Database::commit();
     }
 }
开发者ID:gclove,项目名称:shadowsocks-panel,代码行数:23,代码来源:Message.php


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