Example #1
0
 public function checkConnection()
 {
     $dsn = \Database::newDSN($this->dbtype, $this->dbuser, $this->dbpass, null, $this->dbhost, $this->dbport);
     try {
         $db = \Database::newDB($dsn);
     } catch (\PDOException $e) {
         if ($e->getCode() == 1045) {
             return BRANCH_NO_CONNECTION;
         }
     }
     $db->loadPDO();
     if (!$db->databaseExists($this->dbname)) {
         return BRANCH_CONNECT_NO_DB;
     }
     $dsn->setDatabaseName($this->dbname);
     $db->setDSN($dsn);
     $table_listing = $db->listTables();
     if (!empty($table_listing)) {
         return BRANCH_CONNECT_WITH_TABLES;
     }
     return BRANCH_CONNECT_SUCCESS;
 }