Example #1
0
 public function __construct($dsn, $username = NULL, $password = NULL, array $options = NULL, Reflection\DatabaseReflection $databaseReflection = NULL)
 {
     parent::__construct($this->dsn = $dsn, $username, $password, $options);
     $this->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     $this->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('Nette\\Database\\Statement', array($this)));
     $class = 'Nette\\Database\\Drivers\\' . $this->getAttribute(PDO::ATTR_DRIVER_NAME) . 'Driver';
     if (class_exists($class)) {
         $this->driver = new $class($this, (array) $options);
     }
     $this->preprocessor = new SqlPreprocessor($this);
     $this->databaseReflection = $databaseReflection ?: new Reflection\DatabaseReflection();
     Diagnostics\ConnectionPanel::initialize($this);
 }
Example #2
0
 /**
  * @param \PDOException
  * @return array
  */
 public function renderException($e)
 {
     if ($e instanceof \PDOException && count($this->queries)) {
         $s = '<table><tr><th>Time&nbsp;ms</th><th>SQL</th><th>Params</th>' . ($this->doExplains ? '<th>Explain</th>' : '') . '</tr>';
         $s .= $this->processQuery(end($this->queries));
         $s .= '</table>';
         return array('tab' => 'SQL', 'panel' => $this->renderStyles() . '<div class="nette-inner nette-Doctrine2Panel">' . $s . '</div>');
     } else {
         \Nette\Database\Diagnostics\ConnectionPanel::renderException($e);
     }
 }