Browse Source

Update Connection.php

The docblock seemed to have been lying:

All of the concrete `$this->_driver::connect()` methods (Mysql, PDODriverTrait, Sqlite, Sqlserver, Postgres) seem to do this:

```
    public function connect()
    {
        if ($this->_connection) {
            return true;
        }
        // more code here...
```
inoas 8 years ago
parent
commit
b2822a7fc1
1 changed files with 3 additions and 7 deletions
  1. 3 7
      src/Database/Connection.php

+ 3 - 7
src/Database/Connection.php

@@ -213,20 +213,16 @@ class Connection implements ConnectionInterface
     /**
      * Connects to the configured database.
      *
-     * @throws \Cake\Database\Exception\MissingConnectionException if credentials are invalid
-     * @return bool true on success or false if already connected.
+     * @throws \Cake\Database\Exception\MissingConnectionException if credentials are invalid.
+     * @return bool true, if the connection attempt was successful or already connected.
      */
     public function connect()
     {
         try {
-            $this->_driver->connect();
-
-            return true;
+            return $this->_driver->connect();
         } catch (\Exception $e) {
             throw new MissingConnectionException(['reason' => $e->getMessage()]);
         }
-
-        return false;
     }
 
     /**