Cake\Database\Connection::connect PHP Метод

connect() публичный Метод

Connects to the configured database.
public connect ( ) : boolean
Результат boolean true on success or false if already connected.
    public function connect()
    {
        try {
            $this->_driver->connect();
            return true;
        } catch (Exception $e) {
            throw new MissingConnectionException(['reason' => $e->getMessage()]);
        }
    }

Usage Example

Пример #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();
 }
All Usage Examples Of Cake\Database\Connection::connect