connect() public method

Connects to the configured database.
public connect ( ) : boolean
return boolean true on success or false if already connected.
Beispiel #1
1
 /**
  * Tests that connecting with invalid credentials or database name throws an exception
  *
  * @expectedException \Cake\Database\Exception\MissingConnectionException
  * @return void
  */
 public function testWrongCredentials()
 {
     $config = ConnectionManager::config('test');
     $this->skipIf(isset($config['url']), 'Datasource has dsn, skipping.');
     $connection = new Connection(['database' => '/dev/nonexistent'] + ConnectionManager::config('test'));
     $connection->connect();
 }
 /**
  * Tests that connecting with invalid credentials or database name throws an exception
  *
  * @expectedException \Cake\Database\Error\MissingConnectionException
  * @return void
  **/
 public function testWrongCredentials()
 {
     $config = ConnectionManager::config('test');
     $this->skipIf(isset($config['dsn']), 'Datasource has dsn, skipping.');
     $connection = new Connection(['database' => '_probably_not_there_'] + ConnectionManager::config('test'));
     $connection->connect();
 }