public function connect()
{
if ($this->pdo) {
return;
}
try {
$this->pdo = new PDO($this->params[0], $this->params[1], $this->params[2], $this->options);
$this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (PDOException $e) {
throw ConnectionException::from($e);
}
$class = empty($this->options['driverClass']) ? 'Nette\\Database\\Drivers\\' . ucfirst(str_replace('sql', 'Sql', $this->pdo->getAttribute(PDO::ATTR_DRIVER_NAME))) . 'Driver' : $this->options['driverClass'];
$this->driver = new $class($this, $this->options);
$this->preprocessor = new SqlPreprocessor($this);
$this->onConnect($this);
}