/** * @group DBAL-1215 */ public function testReturnsDatabaseNameWithoutDatabaseNameParameter() { $params = $this->_conn->getParams(); unset($params['dbname']); $connection = new Connection($params, $this->_conn->getDriver(), $this->_conn->getConfiguration(), $this->_conn->getEventManager()); $this->assertSame($this->getDatabaseNameForConnectionWithoutDatabaseNameParameter(), $this->driver->getDatabase($connection)); }
protected function defineDriverName(Driver $driver) { $name = $driver->getName(); if (preg_match('~mysql~', $name) !== 0) { return 'mysql'; } elseif (preg_match('~pgsql~', $name) !== 0) { return 'pgsql'; } else { return $name; } }
public function testReturnsSchemaManager() { $connection = $this->getConnectionMock(); $schemaManager = $this->driver->getSchemaManager($connection); $this->assertEquals($this->createSchemaManager($connection), $schemaManager); $this->assertAttributeSame($connection, '_conn', $schemaManager); }
/** * Initializes a new instance of the Connection class. * * @param array $params The connection parameters. * @param \Doctrine\DBAL\Driver $driver The driver to use. * @param \Doctrine\DBAL\Configuration|null $config The configuration, optional. * @param \Doctrine\Common\EventManager|null $eventManager The event manager, optional. * * @throws \Doctrine\DBAL\DBALException */ public function __construct(array $params, Driver $driver, Configuration $config = null, EventManager $eventManager = null) { $this->_driver = $driver; $this->_params = $params; if (isset($params['pdo'])) { $this->_conn = $params['pdo']; $this->_isConnected = true; } // Create default config and event manager if none given if (!$config) { $config = new Configuration(); } if (!$eventManager) { $eventManager = new EventManager(); } $this->_config = $config; $this->_eventManager = $eventManager; $this->_expr = new Query\Expression\ExpressionBuilder($this); if (!isset($params['platform'])) { $this->_platform = $driver->getDatabasePlatform(); } else { if ($params['platform'] instanceof Platforms\AbstractPlatform) { $this->_platform = $params['platform']; } else { throw DBALException::invalidPlatformSpecified(); } } $this->_platform->setEventManager($eventManager); $this->_transactionIsolationLevel = $this->_platform->getDefaultTransactionIsolationLevel(); }
/** * Gets the SchemaManager that can be used to inspect or change the * database schema through the connection. * * @return \Doctrine\DBAL\Schema\AbstractSchemaManager */ public function getSchemaManager() { if (!$this->_schemaManager) { $this->_schemaManager = $this->_driver->getSchemaManager($this); } return $this->_schemaManager; }
/** * @param \Doctrine\DBAL\Driver $driver * @param \Exception $driverEx * * @return \Doctrine\DBAL\DBALException */ public static function driverException(Driver $driver, \Exception $driverEx) { $msg = "An exception occurred in driver: " . $driverEx->getMessage(); if ($driver instanceof ExceptionConverterDriver && $driverEx instanceof DriverException) { return $driver->convertException($msg, $driverEx); } return new self($msg, 0, $driverEx); }
/** * @param \Doctrine\DBAL\Driver $driver * @param \Exception $driverEx * * @return \Doctrine\DBAL\DBALException */ private static function wrapException(Driver $driver, \Exception $driverEx, $msg) { if ($driverEx instanceof Exception\DriverException) { return $driverEx; } if ($driver instanceof ExceptionConverterDriver && $driverEx instanceof Driver\DriverException) { return $driver->convertException($msg, $driverEx); } return new self($msg, 0, $driverEx); }
/** * @param Driver $driver * @throws \DomainException * @return string */ private function getPropelDriverName(Driver $driver) { $lookup_table = array('pdo_mysql' => 'mysql', 'pdo_pgsql' => 'pgsql', 'pdo_sqlite' => 'sqlite'); if (isset($lookup_table[$driver->getName()])) { return $lookup_table[$driver->getName()]; } throw new \DomainException(sprintf('Unknown driver "%s"', $driver->getName())); }
/** * Initializes a new instance of the Connection class. * * @param array $params The connection parameters. * @param Driver $driver * @param Configuration $config * @param EventManager $eventManager */ public function __construct(array $params, Driver $driver, Configuration $config = null, EventManager $eventManager = null) { $this->_driver = $driver; $this->_params = $params; if (isset($params['pdo'])) { $this->_conn = $params['pdo']; $this->_isConnected = true; } // Create default config and event manager if none given if (!$config) { $config = new Configuration(); } if (!$eventManager) { $eventManager = new EventManager(); } $this->_config = $config; $this->_eventManager = $eventManager; $this->_platform = $driver->getDatabasePlatform(); $this->_transactionIsolationLevel = $this->_platform->getDefaultTransactionIsolationLevel(); $this->_quoteIdentifiers = $config->getQuoteIdentifiers(); $this->_platform->setQuoteIdentifiers($this->_quoteIdentifiers); }
/** * @param \Doctrine\DBAL\Driver $driver * @param \Exception $driverEx * * @return \Doctrine\DBAL\DBALException */ public static function driverException(Driver $driver, \Exception $driverEx) { $msg = "An exception occured in driver: " . $driverEx->getMessage(); return new self($msg, $driver->convertExceptionCode($driverEx), $driverEx); }