public function __construct($config) { // keys must be lowercase $config['portability'] = Connection::PORTABILITY_FIX_CASE; $config['fetch_case'] = \PDO::CASE_LOWER; if ($config['driver'] == 'oracle') { $config['charset'] = 'AL32UTF8'; $config['driver'] = 'oci8'; $config['dbname'] = $config['tns']; unset($config['tns']); $driver = new \Doctrine\DBAL\Driver\OCI8\Driver(); } elseif ($config['driver'] == 'sqlite') { $config['driver'] = 'pdo_sqlite'; $driver = new \Doctrine\DBAL\Driver\PDOSqlite\Driver(); } elseif ($config['driver'] == 'postgres') { $config['driver'] = 'pdo_pgsql'; unset($config['driver']); $driver = new \Doctrine\DBAL\Driver\PDOPgSql\Driver(); } else { throw new \Exception("Unknown driver \"" . $config['driver'] . "\" for database in config"); } parent::__construct($config, $driver); $this->initSession(); $this->beginTransaction(); }
/** * {@inheritDoc} */ public function close() { if ($this->isConnected()) { parent::close(); $this->_isConnected = false; } }
/** * Wraps <tt>Statement</tt> and applies portability measures * * @param \Doctrine\DBAL\Driver\Statement $stmt * @param \Doctrine\DBAL\Connection $conn */ public function __construct($stmt, Connection $conn) { $this->stmt = $stmt; $this->portability = $conn->getPortability(); $this->case = $conn->getFetchCase(); }
public function testPortabilitySqlServer() { $portability = ConnectionPortability::PORTABILITY_SQLSRV; $params = array('portability' => $portability); $driverMock = $this->getMock('Doctrine\\DBAL\\Driver\\PDOSqlsrv\\Driver', array('connect')); $driverMock->expects($this->once())->method('connect')->will($this->returnValue(null)); $connection = new ConnectionPortability($params, $driverMock); $connection->connect($params); $this->assertEquals($portability, $connection->getPortability()); }