Пример #1
0
 /**
  * Check if $table exists in the selected DB
  * 
  * @param string $table - Table name that exists in the selected db
  * @return boolean
  */
 public static function lookupTable($table, $target = "h2owirelessnow")
 {
     $query = " Select count(*) count From systables \n                    Where tabtype ='T'\n                      And tabname = :table\n                 ";
     $var_arr = compact('table');
     try {
         $db = new PDOConnector($target);
         $ret = $db->selectRecords($query, $var_arr);
         $db->close();
         return $ret[0]['count'] ? true : false;
     } catch (PDOException $e) {
         self::displayError("System error occurred.", "Please go back", $e);
     }
 }
 public function checkAndRepairTable($tableName)
 {
     // Flag to ensure we only send the warning about PDO + native mode once
     static $pdo_warning_sent = false;
     // If running PDO and not in emulated mode, check table will fail
     if ($this->database->getConnector() instanceof PDOConnector && !PDOConnector::is_emulate_prepare()) {
         if (!$pdo_warning_sent) {
             $this->alterationMessage('CHECK TABLE command disabled for PDO in native mode', 'notice');
             $pdo_warning_sent = true;
         }
         return true;
     }
     // Perform check
     if (!$this->runTableCheckCommand("CHECK TABLE \"{$tableName}\"")) {
         if ($this->runTableCheckCommand("CHECK TABLE \"" . strtolower($tableName) . "\"")) {
             $this->alterationMessage("Table {$tableName}: renamed from lowercase", "repaired");
             return $this->renameTable(strtolower($tableName), $tableName);
         }
         $this->alterationMessage("Table {$tableName}: repaired", "repaired");
         return $this->runTableCheckCommand("REPAIR TABLE \"{$tableName}\" USE_FRM");
     } else {
         return true;
     }
 }
Пример #3
0
 protected function _execute($query, $var_arr)
 {
     try {
         $db = new PDOConnector($this->db);
         $ret = $db->executeQuery($query, $var_arr);
         $this->affectedRowCounts = $db->affectedRowCounts;
         $db->close();
         return $this->affectedRowCounts;
     } catch (PDOException $e) {
         Util::displayError("System error occurred.", "Please go back", $e);
     }
 }
Пример #4
0
 /**
  * Checks if the user already exists
  * @param $username username for validate
  * @param $email    email for validate
  * @return true (don't registered) false (already exists)
  */
 public function validateUserAlreadyRegistered($username, $email)
 {
     /* @todo This could be abstracted. */
     require APP_DIR . "/database/databaseConnector.php";
     try {
         $PDOConnector = new PDOConnector($mysql);
     } catch (Exception $e) {
         return $this->responseAPI("error", $e->getMessage(), 200);
     }
     $connector = $PDOConnector->getConnection();
     try {
         $getUserData = $connector->prepare("SELECT de_user, de_mail from adm_users WHERE de_user=:de_user OR de_mail=:de_mail");
         $getUserData->bindParam(':de_user', $username, PDO::PARAM_STR);
         $getUserData->bindParam(':de_mail', $email, PDO::PARAM_STR);
         $getUserData->execute();
         $resultData = $getUserData->fetch(PDO::FETCH_ASSOC);
         if (empty($resultData)) {
             return false;
         }
     } catch (Exception $e) {
         return $this->responseAPI("error", $e->getMessage(), 200);
     }
     return true;
 }