[ Index ]

PHP Cross Reference of YOURLS

title

Body

[close]

/includes/vendor/aura/sql/src/ -> DecoratedPdo.php (source)

   1  <?php
   2  /**
   3   *
   4   * This file is part of Aura for PHP.
   5   *
   6   * @license https://opensource.org/licenses/MIT MIT
   7   *
   8   */
   9  namespace Aura\Sql;
  10  
  11  use Aura\Sql\Profiler\Profiler;
  12  use Aura\Sql\Profiler\ProfilerInterface;
  13  use PDO;
  14  
  15  /**
  16   *
  17   * Decorates an existing PDO instance with the extended methods.
  18   *
  19   * @package Aura.Sql
  20   *
  21   */
  22  class DecoratedPdo extends AbstractExtendedPdo
  23  {
  24      /**
  25       *
  26       * Constructor.
  27       *
  28       * This overrides the parent so that it can take an existing PDO instance
  29       * and decorate it with the extended methods.
  30       *
  31       * @param PDO $pdo An existing PDO instance to decorate.
  32       *
  33       * @param ProfilerInterface $profiler Tracks and logs query profiles.
  34       *
  35       */
  36      public function __construct(PDO $pdo, ProfilerInterface $profiler = null)
  37      {
  38          $this->pdo = $pdo;
  39  
  40          if ($profiler === null) {
  41              $profiler = new Profiler();
  42          }
  43          $this->setProfiler($profiler);
  44  
  45          $driver = $pdo->getAttribute(PDO::ATTR_DRIVER_NAME);
  46          $this->setParser($this->newParser($driver));
  47          $this->setQuoteName($driver);
  48      }
  49  
  50      /**
  51       *
  52       * Connects to the database.
  53       *
  54       * @return null
  55       *
  56       */
  57      public function connect()
  58      {
  59          // already connected
  60      }
  61  
  62      /**
  63       *
  64       * Disconnects from the database; disallowed with decorated PDO connections.
  65       *
  66       * @return null
  67       *
  68       */
  69      public function disconnect()
  70      {
  71          $message = "Cannot disconnect a DecoratedPdo instance.";
  72          throw new Exception\CannotDisconnect($message);
  73      }
  74  }


Generated: Thu Sep 19 05:10:04 2024 Cross-referenced by PHPXref 0.7.1