[ Index ]

PHP Cross Reference of phpBB-3.2.11-deutsch

title

Body

[close]

/vendor/symfony/http-kernel/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  @trigger_error('The '.__NAMESPACE__.'\MysqlProfilerStorage class is deprecated since Symfony 2.8 and will be removed in 3.0. Use FileProfilerStorage instead.', E_USER_DEPRECATED);
  15  
  16  /**
  17   * A ProfilerStorage for Mysql.
  18   *
  19   * @author Jan Schumann <js@schumann-it.com>
  20   *
  21   * @deprecated Deprecated since Symfony 2.8, to be removed in Symfony 3.0.
  22   *             Use {@link FileProfilerStorage} instead.
  23   */
  24  class MysqlProfilerStorage extends PdoProfilerStorage
  25  {
  26      /**
  27       * {@inheritdoc}
  28       */
  29      protected function initDb()
  30      {
  31          if (null === $this->db) {
  32              if (0 !== strpos($this->dsn, 'mysql')) {
  33                  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));
  34              }
  35  
  36              if (!class_exists('PDO') || !\in_array('mysql', \PDO::getAvailableDrivers(), true)) {
  37                  throw new \RuntimeException('You need to enable PDO_Mysql extension for the profiler to run properly.');
  38              }
  39  
  40              $db = new \PDO($this->dsn, $this->username, $this->password);
  41              $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, status_code SMALLINT UNSIGNED, KEY (created_at), KEY (ip), KEY (method), KEY (url), KEY (parent))');
  42  
  43              $this->db = $db;
  44          }
  45  
  46          return $this->db;
  47      }
  48  
  49      /**
  50       * {@inheritdoc}
  51       */
  52      protected function buildCriteria($ip, $url, $start, $end, $limit, $method)
  53      {
  54          $criteria = array();
  55          $args = array();
  56  
  57          if ($ip = preg_replace('/[^\d\.]/', '', $ip)) {
  58              $criteria[] = 'ip LIKE :ip';
  59              $args[':ip'] = '%'.$ip.'%';
  60          }
  61  
  62          if ($url) {
  63              $criteria[] = 'url LIKE :url';
  64              $args[':url'] = '%'.addcslashes($url, '%_\\').'%';
  65          }
  66  
  67          if ($method) {
  68              $criteria[] = 'method = :method';
  69              $args[':method'] = $method;
  70          }
  71  
  72          if (!empty($start)) {
  73              $criteria[] = 'time >= :start';
  74              $args[':start'] = $start;
  75          }
  76  
  77          if (!empty($end)) {
  78              $criteria[] = 'time <= :end';
  79              $args[':end'] = $end;
  80          }
  81  
  82          return array($criteria, $args);
  83      }
  84  }


Generated: Wed Nov 11 20:33:01 2020 Cross-referenced by PHPXref 0.7.1