/** * @param null|\Pixie\Connection $connection * * @throws \Pixie\Exception */ public function __construct(Connection $connection = null) { if (is_null($connection)) { if (!($connection = Connection::getStoredConnection())) { throw new Exception('No database connection found.', 1); } } $this->connection = $connection; $this->container = $this->connection->getContainer(); $this->pdo = $this->connection->getPdoInstance(); $this->adapter = $this->connection->getAdapter(); $this->adapterConfig = $this->connection->getAdapterConfig(); if (isset($this->adapterConfig['prefix'])) { $this->tablePrefix = $this->adapterConfig['prefix']; } // Query builder adapter instance $this->adapterInstance = $this->container->build('\\Pixie\\QueryBuilder\\Adapters\\' . ucfirst($this->adapter), array($this->connection)); $this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); }
public function __construct(Connection $connection) { $this->connection = $connection; $this->container = $this->connection->getContainer(); }