Пример #1
0
 public static function deleteFrom($tableID, $whereArr, $returnTable = NULL)
 {
     //----------------------------------------------------------
     //init var
     //----------------------------------------------------------
     $chk = array("bool" => true, 'function' => "deleteFrom");
     //----------------------------------------------------------
     $tableID = GlobalMas::$mysqli->real_escape_string($tableID);
     //----------------------------------------------------------
     $queryString = "DELETE FROM " . $tableID . " ";
     //----------------------------------------------------------
     $queryString = MySQL::condition($tableID, $whereArr, "where", $queryString);
     //----------------------------------------------------------
     $result = GlobalMas::$mysqli->query($queryString);
     //----------------------------------------------------------
     if (GlobalMas::$debug) {
         $chk["queryString"] = $queryString;
     }
     //----------------------------------------------------------
     if ($result) {
         $chk["bool"] = true;
         $chk["message"] = "delete complete";
         if ($returnTable) {
             $chk = call_user_func_array(array(MySQL, "getTable"), array($tableID));
         }
     } else {
         $chk["bool"] = false;
         $chk['error'] = true;
         $chk["message"] = GlobalMas::$mysqli->error(GlobalMas::$mysqli);
     }
     //----------------------------------------------------------
     return $chk;
     //----------------------------------------------------------
 }
Пример #2
0
 public function getQueryString()
 {
     //----------------------------------------------------------
     //init var
     //----------------------------------------------------------
     $chk = array("bool" => true, "traceID" => "getTable");
     //----------------------------------------------------------
     $this->tableID = Constants::$mysqli->real_escape_string($this->tableID);
     //----------------------------------------------------------
     $queryString = "SELECT " . $this->tableID . ".*";
     $queryString .= " FROM " . $this->tableID;
     //----------------------------------------------------------
     if (!is_null($this->whereArr)) {
         $queryString = MySQL::condition($this->tableID, $this->whereArr, "where", $queryString);
     }
     //----------------------------------------------------------
     return $queryString;
 }
Пример #3
0
 public function update()
 {
     //----------------------------------------------------------
     //init var
     //----------------------------------------------------------
     $chk = array("bool" => true, 'function' => "update");
     //----------------------------------------------------------
     $this->tableID = GlobalMas::$mysqli->real_escape_string($this->tableID);
     //----------------------------------------------------------
     $this->queryString = "UPDATE " . $this->tableID . " ";
     //----------------------------------------------------------
     $this->queryString = MySQL::condition($this->tableID, $this->setArr, "set", $this->queryString);
     $this->queryString = MySQL::condition($this->tableID, $this->whereArr, "where", $this->queryString);
     //----------------------------------------------------------
     $chk = $this->getResult();
     //----------------------------------------------------------
     if ($this->returnTable) {
         $chk = GetTable::go($this->tableID, $this->whereArr);
     }
     //----------------------------------------------------------
     return $chk;
     //----------------------------------------------------------
 }
Пример #4
0
 public function insertINTO()
 {
     //----------------------------------------------------------
     //init var
     //----------------------------------------------------------
     $chk = array("bool" => true, 'function' => "insertINTO");
     $this->updateArr = array();
     //----------------------------------------------------------
     $chk = GenFun::errorKey_chk($this->setArr, NULL, true);
     //----------------------------------------------------------
     $this->setArr = $chk['valueArr'];
     //----------------------------------------------------------
     if (!$chk['bool']) {
         return $chk;
     }
     //----------------------------------------------------------
     $this->tableID = Constants::$mysqli->real_escape_string($this->tableID);
     //----------------------------------------------------------
     $this->queryString = $this->insertType . " " . $this->tableID . " (";
     foreach ($this->setArr as $i => $value) {
         if (strrpos($value, "{hash}") === 0) {
             $this->updateArr[$i] = $value;
         } else {
             $this->queryString .= $i . ",";
         }
     }
     //----------------------------------------------------------
     foreach ($this->updateArr as $i => $value) {
         unset($this->setArr[$i]);
     }
     //----------------------------------------------------------
     $this->queryString = substr($this->queryString, 0, -1);
     $this->queryString .= ") ";
     //----------------------------------------------------------
     $keys = array_keys($this->setArr);
     $this->queryString .= "VALUES ";
     //----------------------------------------------------------
     $high = sizeof($this->setArr[$keys[0]]);
     for ($i = 1; $i < sizeof($this->setArr); $i++) {
         if (is_array($this->setArr[$keys[$i]])) {
             $cur = sizeof($this->setArr[$keys[$i]]);
             if ($high < $cur) {
                 $high = $cur;
             }
         }
     }
     //----------------------------------------------------------
     for ($i = 0; $i < 1; $i++) {
         $value = $this->setArr[$keys[$i]];
         $num = is_array($value) ? sizeof($value) : 1;
         for ($j = 0; $j < $high; $j++) {
             if (is_array($this->setArr[$keys[$i]])) {
                 $value = $this->setArr[$keys[$i]][$j];
             }
             if ($i == 0) {
                 $this->queryString .= "(";
             }
             if (strrpos($value, "(") !== false && strrpos($value, "(") == 0 && !$this->ignore) {
                 $this->queryString .= $value;
                 //$this->queryString .= ",";
             } else {
                 if ($value == "DEFAULT") {
                     $this->queryString .= $value;
                 } else {
                     $this->queryString .= "'" . Constants::$mysqli->escape_string($value) . "'";
                 }
             }
             //-------------------------------------------------
             for ($k = 0; $k < sizeof($this->setArr); $k++) {
                 if ($keys[$k] != $keys[$i]) {
                     $this->queryString .= ",";
                     if (is_array($this->setArr[$keys[$k]])) {
                         $v = $this->setArr[$keys[$k]][$j];
                         $this->queryString .= "'" . Constants::$mysqli->escape_string($v) . "'";
                     } else {
                         $v = $this->setArr[$keys[$k]];
                         $this->queryString .= "'" . Constants::$mysqli->escape_string($v) . "'";
                     }
                 }
             }
             //-------------------------------------------------
             //if ($i == sizeof($this->setArr)-1) {
             //$this->queryString = substr($this->queryString, 0, -1);
             $this->queryString .= ")";
             //}
             //-------------------------------------------------
             if ($j < $high - 1) {
                 $this->queryString .= ",";
             }
         }
     }
     //----------------------------------------------------------
     if (!is_null($this->onDuplicate)) {
         $this->queryString .= " ON DUPLICATE KEY UPDATE ";
         $this->queryString = MySQL::condition($this->tableID, $this->onDuplicate, NULL, $this->queryString);
     }
     //----------------------------------------------------------
     if (!$this->returnQuery) {
         $chk = $this->getResult();
         $insert_id = $chk['insert_id'];
         if ($chk['duplicate']) {
             $chk['duplicate'] = GetTable::go($this->tableID, $this->setArr);
         } else {
             if (sizeof($this->updateArr) > 0) {
                 foreach ($this->updateArr as $i => $value) {
                     if (strrpos($value, "{hash}") === 0) {
                         $value = strtr($value, array('{hash}' => ""));
                         /*if (!is_numeric($value)) {
                         			$chk['bool'] = false;
                         			$chk['messgae'] = "In order to use the alphaID() utility ".$value.' must be numeric!!!';
                         			return $chk;
                         		}*/
                         $this->updateArr[$i] = alphaID($insert_id . $value);
                     }
                 }
                 $this->setArr['id'] = $insert_id;
                 $chk = Update::go($this->tableID, $this->updateArr, $this->setArr);
             }
         }
         if (!$chk['bool']) {
             return $chk;
         }
         if ($this->returnRow) {
             $chk['row'] = GetTable::go($this->tableID, array("id" => $insert_id));
             if ($chk['row']['bool']) {
                 $chk['row'] = $chk['row']['result'][0];
             }
         }
         $chk['insert_id'] = $insert_id;
         return $chk;
     } else {
         return $this->queryString;
     }
 }
Пример #5
0
 public function getPlayerEmails($obj)
 {
     $queryString .= "SELECT accounts.email FROM accounts";
     $queryString = MySQL::condition($queryString, array("id" => array("obj" => $obj, "prop" => "id")), "where", $tableID);
     $chk = Result::go($queryString);
     return $chk;
 }
Пример #6
0
 private function _getVideos($filters = NULL, $returnQuery = false)
 {
     //----------------------------------------------------------
     //init var
     //----------------------------------------------------------
     $resultObj = array_merge(array("chkForQuery" => true, 'returnQuery' => $returnQuery), $this->resultObj);
     $chk = array("bool" => true, "traceID" => "_getVideos");
     //----------------------------------------------------------
     $queryString = $this->getVideo(NULL, true);
     //----------------------------------------------------------
     $queryString = MySQL::condition("videos", $filters, "and", $queryString);
     $queryString .= " ORDER BY videos.id DESC";
     //----------------------------------------------------------
     if ($returnQuery) {
         return $queryString;
     }
     //----------------------------------------------------------
     $chk = Result::go($queryString, $resultObj);
     //----------------------------------------------------------
     $chk['result'] = $this->encodeResult($chk['result']);
     //----------------------------------------------------------
     return $chk;
 }