/** * Connects to the configured database. * * @throws \Cake\Database\Exception\MissingConnectionException if credentials are invalid * @return bool 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()]); } }
/** * Constructor * * This constructor will connect the driver so that methods like columnSql() and others * will fail when the driver has not been connected. * * @param \Cake\Database\Driver $driver The driver to use. */ public function __construct(Driver $driver) { $driver->connect(); $this->_driver = $driver; }