/** * @group DBAL-1215 */ public function testConnectsWithoutDatabaseNameParameter() { $params = $this->_conn->getParams(); unset($params['dbname']); $user = isset($params['user']) ? $params['user'] : null; $password = isset($params['password']) ? $params['password'] : null; $connection = $this->driver->connect($params, $user, $password); $this->assertInstanceOf('Doctrine\\DBAL\\Driver\\Connection', $connection); }
/** * Establishes the connection with the database. * * @return boolean TRUE if the connection was successfully established, FALSE if * the connection is already open. */ public function connect() { if ($this->_isConnected) { return false; } $driverOptions = isset($this->_params['driverOptions']) ? $this->_params['driverOptions'] : array(); $user = isset($this->_params['user']) ? $this->_params['user'] : null; $password = isset($this->_params['password']) ? $this->_params['password'] : null; $this->_conn = $this->_driver->connect($this->_params, $user, $password, $driverOptions); $this->_isConnected = true; if ($this->_eventManager->hasListeners(Events::postConnect)) { $eventArgs = new Event\ConnectionEventArgs($this); $this->_eventManager->dispatchEvent(Events::postConnect, $eventArgs); } return true; }
/** * Establishes the connection with the database. * * @return boolean TRUE if the connection was successfully established, FALSE if * the connection is already open. */ public function connect() { if ($this->_isConnected) { return false; } $driverOptions = isset($this->_params['driverOptions']) ? $this->_params['driverOptions'] : array(); $user = isset($this->_params['user']) ? $this->_params['user'] : null; $password = isset($this->_params['password']) ? $this->_params['password'] : null; $this->_conn = $this->_driver->connect($this->_params, $user, $password, $driverOptions); $this->_isConnected = true; if (null === $this->platform) { $this->detectDatabasePlatform(); } if (false === $this->autoCommit) { $this->beginTransaction(); } if ($this->_eventManager->hasListeners(Events::postConnect)) { $eventArgs = new Event\ConnectionEventArgs($this); $this->_eventManager->dispatchEvent(Events::postConnect, $eventArgs); } return true; }