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


PHP Database::unlockTables方法代码示例

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


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

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

示例2: getmypid

    LIMIT 1;');
// No waiting jobs in queue.
if (!$process) {
    Database::unlockTables(true);
    Database::rollback();
    Log::debug('No more jobs to do, suicide.');
    die;
}
$processContents = (array) ContentDecoder::json($process[Node::FIELD_VIRTUAL], 1);
unset($process[Node::FIELD_VIRTUAL]);
$process += $processContents;
unset($processContents);
$res = Database::query('UPDATE `' . FRAMEWORK_COLLECTION_PROCESS . '` SET `pid` = ?
    WHERE `id` = ? AND `pid` IS NULL LIMIT 1', [getmypid(), $process['id']]);
// Commit transaction
Database::unlockTables(true);
Database::commit();
if ($res->rowCount() < 1) {
    Log::warning('Unable to update process pid, worker exits.');
    die;
} else {
    $process['pid'] = getmypid();
    $process[Node::FIELD_COLLECTION] = FRAMEWORK_COLLECTION_PROCESS;
}
// Check if $env specified in option
if (@$_SERVER['env']) {
    $_SERVER['env'] = ContentDecoder::json($_SERVER['env'], 1);
}
// More debug logs
Log::debug("Execute process: {$process['command']}");
// Spawn process and retrieve the pid
开发者ID:Victopia,项目名称:prefw,代码行数:31,代码来源:Process.php

示例3: set

 /**
  * Updates process related info of specified property $name.
  *
  * Note: Updates to real table properties are ignored, as they are requried
  * by the process framework.
  */
 public static function set($name, $value)
 {
     Database::lockTables(FRAMEWORK_COLLECTION_PROCESS, FRAMEWORK_COLLECTION_LOG);
     $res = self::get();
     if (!$res) {
         Database::unlockTables();
         return false;
     }
     $readOnlyFields = ['id', 'command', 'type', 'weight', 'pid', 'timestamp'];
     if (in_array($name, $readOnlyFields)) {
         Database::unlockTables();
         return false;
     }
     if (is_null($value)) {
         unset($res[$name]);
     } else {
         $res[$name] = $value;
     }
     unset($res['timestamp']);
     $ret = Node::set($res);
     Database::unlockTables();
     // Clear data cache
     self::$_processData = null;
     return $ret;
 }
开发者ID:Victopia,项目名称:prefw,代码行数:31,代码来源:Process.php


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