public function __construct(DSN $dsn) { if (!$dsn->isSQLite()) { throw new ConfigurationException(sprintf("\\%s expects a DSN of type '%s', '%s' given", __CLASS__, DSN::TYPE_SQLITE, $dsn->type)); } parent::__construct($dsn); }
public function quoteIdentifier($name) { $name = trim($name); if ($name == '*') { return $name; } // ANSI-SQL (everything else) says to use double quotes to quote identifiers $char = '"'; // MySQL uses backticks cos it's special if ($this->dsn->isMySQL()) { $char = '`'; } return $char . $name . $char; }
protected function db($name, Config $config) { if (!($config = $config->get("databases.{$name}"))) { throw new \LogicException("No configuration for database '{$name}'"); } if (is_array($config)) { $dsn = new DSN($config); } else { $dsn = DSN::fromString($config); } $db = parent::offsetGet('db')->add($name, $dsn); parent::offsetExists('profiler') && $db->setProfiler(parent::offsetGet('profiler')); return $db; }
/** * Ensure we have a valid DSN instance. * @param mixed $dsn a string, array or DSN instance * @return DSN */ protected function validateDSN($dsn) { if ($dsn instanceof DSN) { return $dsn; } elseif (is_string($dsn)) { return DSN::fromString($dsn); } elseif (is_array($dsn)) { return new DSN($dsn); } else { throw new ConfigurationException('Invalid DSN: ' . $dsn); } }