[ Index ]

PHP Cross Reference of phpBB-3.1.12-deutsch

title

Body

[close]

/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/ -> MysqlProfilerStorage.php (source)

   1  <?php
   2  
   3  /*
   4   * This file is part of the Symfony package.
   5   *
   6   * (c) Fabien Potencier <fabien@symfony.com>
   7   *
   8   * For the full copyright and license information, please view the LICENSE
   9   * file that was distributed with this source code.
  10   */
  11  
  12  namespace Symfony\Component\HttpKernel\Profiler;
  13  
  14  /**
  15   * A ProfilerStorage for Mysql.
  16   *
  17   * @author Jan Schumann <js@schumann-it.com>
  18   */
  19  class MysqlProfilerStorage extends PdoProfilerStorage
  20  {
  21      /**
  22       * {@inheritdoc}
  23       */
  24      protected function initDb()
  25      {
  26          if (null === $this->db) {
  27              if (0 !== strpos($this->dsn, 'mysql')) {
  28                  throw new \RuntimeException(sprintf('Please check your configuration. You are trying to use Mysql with an invalid dsn "%s". The expected format is "mysql:dbname=database_name;host=host_name".', $this->dsn));
  29              }
  30  
  31              if (!class_exists('PDO') || !in_array('mysql', \PDO::getAvailableDrivers(), true)) {
  32                  throw new \RuntimeException('You need to enable PDO_Mysql extension for the profiler to run properly.');
  33              }
  34  
  35              $db = new \PDO($this->dsn, $this->username, $this->password);
  36              $db->exec('CREATE TABLE IF NOT EXISTS sf_profiler_data (token VARCHAR(255) PRIMARY KEY, data LONGTEXT, ip VARCHAR(64), method VARCHAR(6), url VARCHAR(255), time INTEGER UNSIGNED, parent VARCHAR(255), created_at INTEGER UNSIGNED, KEY (created_at), KEY (ip), KEY (method), KEY (url), KEY (parent))');
  37  
  38              $this->db = $db;
  39          }
  40  
  41          return $this->db;
  42      }
  43  
  44      /**
  45       * {@inheritdoc}
  46       */
  47      protected function buildCriteria($ip, $url, $start, $end, $limit, $method)
  48      {
  49          $criteria = array();
  50          $args = array();
  51  
  52          if ($ip = preg_replace('/[^\d\.]/', '', $ip)) {
  53              $criteria[] = 'ip LIKE :ip';
  54              $args[':ip'] = '%'.$ip.'%';
  55          }
  56  
  57          if ($url) {
  58              $criteria[] = 'url LIKE :url';
  59              $args[':url'] = '%'.addcslashes($url, '%_\\').'%';
  60          }
  61  
  62          if ($method) {
  63              $criteria[] = 'method = :method';
  64              $args[':method'] = $method;
  65          }
  66  
  67          if (!empty($start)) {
  68              $criteria[] = 'time >= :start';
  69              $args[':start'] = $start;
  70          }
  71  
  72          if (!empty($end)) {
  73              $criteria[] = 'time <= :end';
  74              $args[':end'] = $end;
  75          }
  76  
  77          return array($criteria, $args);
  78      }
  79  }


Generated: Thu Jan 11 00:25:41 2018 Cross-referenced by PHPXref 0.7.1