Beispiel #1
0
 /**
  * Establish a new database connection
  * 
  * @param string $type
  * @param string $hostname
  * @param int $port
  * @param string $username
  * @param string $password
  * @param string $key
  * 
  * @return Connection
  */
 public function establishConnection($type, $hostname, $port, $username, $password, &$key)
 {
     $key = NULL;
     $connection = Connection::create($type, $hostname, $port, $username, $password, $key);
     $driver = $this->drivers->getDriver($type);
     // Test the connection
     if (!$driver->testConnection($connection)) {
         return null;
     }
     // Success, build and store the connection
     $store = $this->getStore();
     $store->add($connection);
     // Lock (encrypt) the credentials and return the private key
     $connection->lock();
     return $connection;
 }