public function insertComment($obj) { //---------------------------------------------------------- //init var //---------------------------------------------------------- $resultObj = array_merge(array('returnQuery' => $returnQuery), $this->resultObj); $chk = array("bool" => true, "traceID" => "insertComments"); //---------------------------------------------------------- $chk = GenFun::errorKey_CHK($obj['set'], array("comment", "content_id")); //---------------------------------------------------------- if (!$chk['bool']) { return $chk; } //---------------------------------------------------------- $obj['set']['comment'] = stripslashes($obj['set']['comment']); //---------------------------------------------------------- $chk = InsertINTO::go("comments", array("comment" => $obj['set']['comment'], "accounts_id" => is_null(GlobalMas::$loggedIN) ? $this->guest_id : GlobalMas::$loggedIN['id'], 'reply_comments_id' => $obj['set']['reply_comments_id'], 'commentType' => $this->commentType, 'content_id' => $obj['set']['content_id'])); //---------------------------------------------------------- if ($chk['bool']) { $comment_id = $chk['insert_id']; } //---------------------------------------------------------- if ($chk['bool']) { $chk = Result::resetQueries(); } //---------------------------------------------------------- //$setArr = array('reply_comments_id' => $obj['set']['reply_comments_id'], "comments_id" => $comment_id, "content_id" => $obj['set']['content_id']); //---------------------------------------------------------- //if ($chk['bool']) $chk = InsertINTO::go($this->contentComments_tbl, $setArr, array('resetQueries' => true)); //---------------------------------------------------------- if ($chk['bool']) { $chk = $this->_getComments(NULL, $comment_id); } //---------------------------------------------------------- return $chk; }
public function getResult() { if (is_null($this->mysqli)) { $this->mysqli = GlobalMas::$mysqli; } //---------------------------------------------------------- //init var //---------------------------------------------------------- $chk = array("bool" => true, 'traceID' => "getResult"); $update = false; //---------------------------------------------------------- if ($this->returnQuery) { return $this->queryString; } //---------------------------------------------------------- $chk = GenFun::debugChk($chk, array("queryString" => $this->queryString)); //---------------------------------------------------------- $debug = GlobalMas::$debug; //---------------------------------------------------------- if ($this->chkForQuery) { $query_chk = Result::go("SELECT queries.result, queries.last_update FROM queries WHERE queries.query = '" . $this->mysqli->escape_string($this->queryString) . "'"); //------------------------------------------------------ if (sizeof($query_chk['result']) > 0) { if (empty($query_chk['result'][0]['last_update']) || is_null($query_chk['result'][0]['last_update'])) { $update = true; } if (!$update) { $chk = json_decode($query_chk['result'][0]['result'], true); //---------------------------------------------- $chk = self::debug_chk($chk); //---------------------------------------------- return $chk; } } } //---------------------------------------------------------- $result = $this->multi ? $this->mysqli->multi_query($this->queryString) : $this->mysqli->query($this->queryString); //---------------------------------------------------------- if (!$result) { $chk['bool'] = false; $chk['error'] = false; $chk = GenFun::debugCHK($chk, array('message' => $this->mysqli->error)); if (strpos($chk['message'], "Duplicate") !== false) { return $chk['duplicate'] = true; } } //---------------------------------------------------------- if ($this->multi) { $result = $this->getMultiQueryResult($result); } else { $result = $this->getSingleQueryResult($result); //---------------------------------------------- if ($this->greaterZero) { if (sizeof($result) == 0) { $chk['bool'] = false; } } } $chk['result'] = $result; //---------------------------------------------------------- $this->insert_id = $this->mysqli->insert_id; $chk['insert_id'] = $this->insert_id; //-------------------------------------------------- if ($this->chkForQuery) { $queryString = $this->mysqli->real_escape_string($this->queryString); $resultString = $this->mysqli->real_escape_string(json_encode($chk)); if (!$update) { $query_chk = Result::go("INSERT INTO queries (query, result)\r\n\t\t\t\t SELECT * FROM (SELECT '" . $queryString . "', '" . $resultString . "') AS tmp\r\n\t\t\t\tWHERE NOT EXISTS (\r\n\t\t\t\t\tSELECT query FROM queries WHERE query = '" . $queryString . "'\r\n\t\t\t\t) LIMIT 1"); } else { $query_chk = Result::go("UPDATE queries SET queries.query = '" . $queryString . "', queries.result = '" . $resultString . "', queries.last_update = NOW() WHERE queries.query = '" . $queryString . "'"); } //---------------------------------------------- GlobalMas::$debug = $debug; } //------------------------------------------------------ $chk = self::debug_chk($chk); //------------------------------------------------------ if ($this->resetQueries) { $chk['resetQueries'] = Result::resetQueries(); } //------------------------------------------------------ return $chk; }
public function _agreeWith_comment($accounts_id, $comments_id, $agree = "1", $returnQuery = NULL) { $chk = GenFun::error_chk(array($accounts_id, $comments_id)); if ($chk['bool']) { $chk = InsertINTO::go("agreeWith", array("accounts_id" => $accounts_id, "comments_id" => $comments_id, "agree" => $agree)); //---------------------------------------------------------- if ($chk['bool']) { $chk = Result::resetQueries(); } //---------------------------------------------------------- } return $chk; }
public function getResult() { //---------------------------------------------------------- //init var //---------------------------------------------------------- $chk = array("bool" => true, 'traceID' => "getResult"); $update = false; //---------------------------------------------------------- if ($this->returnQuery) { return $this->queryString; } //---------------------------------------------------------- $chk = GenFun::debugChk($chk, array("queryString" => $this->queryString)); //---------------------------------------------------------- $debug = Constants::$debug; //---------------------------------------------------------- if ($this->chkForQuery) { $query_chk = Result::go("SELECT queries.result, queries.last_update FROM queries WHERE queries.query = '" . Constants::$mysqli->escape_string($this->queryString) . "'"); //------------------------------------------------------ if (sizeof($query_chk['result']) > 0) { if (empty($query_chk['result'][0]['last_update']) || is_null($query_chk['result'][0]['last_update'])) { $update = true; } if (!$update) { $chk = json_decode($query_chk['result'][0]['result'], true); //---------------------------------------------- $chk = self::debug_chk($chk); //---------------------------------------------- return $chk; } } } //---------------------------------------------------------- $result = $multi ? Constants::$mysqli->multi_query($this->queryString) : Constants::$mysqli->query($this->queryString); //---------------------------------------------------------- if ($result) { $chk['bool'] = true; $arr = array(); if ($result) { //-------------------------------------------------- $this->insert_id = Constants::$mysqli->insert_id; $chk['insert_id'] = $this->insert_id; //-------------------------------------------------- if ($multi) { $result = Constants::$mysqli->use_result(); } //-------------------------------------------------- if ($result && is_object($result)) { while ($row = $result->fetch_assoc()) { array_push($arr, $row); } //---------------------------------------------- if ($this->greaterZero) { if (sizeof($arr) == 0) { $chk['bool'] = false; } } //---------------------------------------------- $chk['result'] = $arr; } } //Constants::$debug = false; //-------------------------------------------------- if ($this->chkForQuery) { $queryString = Constants::$mysqli->real_escape_string($this->queryString); $resultString = Constants::$mysqli->real_escape_string(json_encode($chk)); if (!$update) { $query_chk = Result::go("INSERT INTO queries (query, result)\n\t\t\t\t\t SELECT * FROM (SELECT '" . $queryString . "', '" . $resultString . "') AS tmp\n\t\t\t\t\tWHERE NOT EXISTS (\n\t\t\t\t\t\tSELECT query FROM queries WHERE query = '" . $queryString . "'\n\t\t\t\t\t) LIMIT 1"); } else { $query_chk = Result::go("UPDATE queries SET queries.query = '" . $queryString . "', queries.result = '" . $resultString . "', queries.last_update = NOW() WHERE queries.query = '" . $queryString . "'"); } //---------------------------------------------- Constants::$debug = $debug; } } else { $chk['bool'] = false; $chk['error'] = true; $chk = GenFun::debugCHK($chk, array('message' => Constants::$mysqli->error)); if (strpos($chk['message'], "Duplicate") !== false) { $chk['duplicate'] = true; } } //------------------------------------------------------ $chk = self::debug_chk($chk); //------------------------------------------------------ if ($this->resetQueries) { $chk['resetQueries'] = Result::resetQueries(); } //------------------------------------------------------ return $chk; }