當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Connection::getLogger方法代碼示例

本文整理匯總了PHP中Drupal\Core\Database\Connection::getLogger方法的典型用法代碼示例。如果您正苦於以下問題:PHP Connection::getLogger方法的具體用法?PHP Connection::getLogger怎麽用?PHP Connection::getLogger使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Drupal\Core\Database\Connection的用法示例。


在下文中一共展示了Connection::getLogger方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: execute

 /**
  * {@inheritdoc}
  */
 public function execute($args = array(), $options = array())
 {
     if (isset($options['fetch'])) {
         if (is_string($options['fetch'])) {
             // \PDO::FETCH_PROPS_LATE tells __construct() to run before properties
             // are added to the object.
             $this->setFetchMode(\PDO::FETCH_CLASS | \PDO::FETCH_PROPS_LATE, $options['fetch']);
         } else {
             $this->setFetchMode($options['fetch']);
         }
     }
     $logger = $this->dbh->getLogger();
     if (!empty($logger)) {
         $query_start = microtime(TRUE);
     }
     $return = parent::execute($args);
     if (!empty($logger)) {
         $query_end = microtime(TRUE);
         $logger->log($this, $args, $query_end - $query_start);
     }
     return $return;
 }
開發者ID:ddrozdik,項目名稱:dmaps,代碼行數:25,代碼來源:Statement.php

示例2: collect

 /**
  * {@inheritdoc}
  */
 public function collect(Request $request, Response $response, \Exception $exception = NULL)
 {
     $queries = $this->database->getLogger()->get('webprofiler');
     foreach ($queries as &$query) {
         // Remove caller args.
         unset($query['caller']['args']);
         // Remove query args element if empty.
         if (empty($query['args'])) {
             unset($query['args']);
         }
         // Save time in milliseconds.
         $query['time'] = $query['time'] * 1000;
     }
     $querySort = $this->configFactory->get('webprofiler.config')->get('query_sort');
     if ('duration' === $querySort) {
         usort($queries, ["Drupal\\webprofiler\\DataCollector\\DatabaseDataCollector", "orderQueryByTime"]);
     }
     $this->data['queries'] = $queries;
     $options = $this->database->getConnectionOptions();
     // Remove password for security.
     unset($options['password']);
     $this->data['database'] = $options;
 }
開發者ID:ABaldwinHunter,項目名稱:durhamatletico-cms,代碼行數:26,代碼來源:DatabaseDataCollector.php

示例3: execute

 /**
  * {@inheritdoc}
  */
 public function execute($args = array(), $options = array())
 {
     if (isset($options['fetch'])) {
         if (is_string($options['fetch'])) {
             // Default to an object. Note: db fields will be added to the object
             // before the constructor is run. If you need to assign fields after
             // the constructor is run. See https://www.drupal.org/node/315092.
             $this->setFetchMode(\PDO::FETCH_CLASS, $options['fetch']);
         } else {
             $this->setFetchMode($options['fetch']);
         }
     }
     $logger = $this->dbh->getLogger();
     if (!empty($logger)) {
         $query_start = microtime(TRUE);
     }
     // Prepare the query.
     $statement = $this->getStatement($this->queryString, $args);
     if (!$statement) {
         $this->throwPDOException();
     }
     $return = $statement->execute($args);
     if (!$return) {
         $this->throwPDOException();
     }
     if ($options['return'] == Database::RETURN_AFFECTED) {
         $this->rowCount = $statement->rowCount();
     }
     // Fetch all the data from the reply, in order to release any lock
     // as soon as possible.
     $this->data = $statement->fetchAll(\PDO::FETCH_ASSOC);
     // Destroy the statement as soon as possible. See the documentation of
     // \Drupal\Core\Database\Driver\sqlite\Statement for an explanation.
     unset($statement);
     $this->resultRowCount = count($this->data);
     if ($this->resultRowCount) {
         $this->columnNames = array_keys($this->data[0]);
     } else {
         $this->columnNames = array();
     }
     if (!empty($logger)) {
         $query_end = microtime(TRUE);
         $logger->log($this, $args, $query_end - $query_start);
     }
     // Initialize the first row in $this->currentRow.
     $this->next();
     return $return;
 }
開發者ID:Greg-Boggs,項目名稱:electric-dev,代碼行數:51,代碼來源:StatementPrefetch.php


注:本文中的Drupal\Core\Database\Connection::getLogger方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。