/** * * Connect to the database. * * @param array $data the data to connect the database. * @param string $login the login (if not provided in the $data array) * @param string $password the password (if not provided in the $data array) * @throws DAOException a DAOException (or a SQLException). */ protected function connect($data, $login = null, $password = null) { if (!is_array($data)) { // Apply as an array $data = ['dsn' => $data]; } try { $dsn = $data['dsn']; $this->db = parent::connect($data, $login, $password); if (Concerto\std::beginsWith($dsn, "mysql:")) { $this->converter = new MySQLConverter(); } else { $this->log("Unknown database converter -- using basic converter instead"); $this->converter = new BasicConverter(); } } catch (SQLException $e) { throw new DAOException("Can not connect to database.", SQL::CONNECT_ERROR, $e); } }