db = $db; $this->db->errorFormat = "json"; }//end function init function check($tabledefuuid, $columname, $value, $excludeid = NULL){ $querystatement = " SELECT `maintable` FROM `tabledefs` WHERE `uuid` = '".mysql_real_escape_string($tabledefuuid)."'"; $queryresult = $this->db->query($querystatement); if($this->db->numRows($queryresult) === 0) return "error"; $therecord = $this->db->fetchArray($queryresult); $table = $therecord["maintable"]; $columname = mysql_real_escape_string(str_replace("`","", $columname)); $value = mysql_real_escape_string($value); $querystatement = " SELECT count(id) AS thecount FROM `".$table."` WHERE `".$columname."` = '".$value."'"; if($excludeid){ $querystatement .= " AND `uuid` != '".mysql_real_escape_string($excludeid)."'"; }//endif $queryresult = $this->db->query($querystatement); $therecord = $this->db->fetchArray($queryresult); return ($therecord["thecount"] == 0); }//end function check }//end class /** * PROCESSING ================================================================== */ if(!isset($noOutput)){ require_once("include/session.php"); if(!isset($_GET["tduuid"]) || !isset($_GET["cname"]) || !isset($_GET["value"])) $error = new appError(200, "passed parameters not set"); if(!isset($_GET["xuuid"])) $_GET["xuuid"] = ""; $checker = new uniqueChecker($db); echo json_encode($checker->check($_GET["tduuid"], $_GET["cname"], $_GET["value"], $_GET["xuuid"])); }//endif