当前位置: 首页>>代码示例>>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;未经允许,请勿转载。