showErr = 1; break; } /* SERVER_NAME */ } /* ********** ********** ********** ********** ********** */ private function ShowErrMsg($msg) { echo "
"; echo "SQL Error!!

"; echo $msg; echo "
"; } /* ********** ********** ********** ********** ********** */ function connDB() { $this->conn = @mysqli_connect($this->hostName , $this->usrName , $this->usrPwd , $this->dbName ); if ($this->isUTF8) { $this->charUTF8(); } } /* ********** ********** ********** ********** ********** */ function charUTF8() { @mysqli_set_charset($this->conn, 'utf8'); } /* ********** ********** ********** ********** ********** */ function execQuery($sql) { $result = @mysqli_query($this->conn, $sql); $DebugMode = ($_SERVER['SERVER_NAME'] == 'localhost' || $_SERVER['SERVER_NAME'] == 'dev.debug' || $_SERVER['SERVER_NAME'] == 'dev.test'); $DebugMode = true; if (@mysqli_error($this->conn) && $DebugMode) { echo "
"; echo "SQL Error: "; echo "
"; echo @mysqli_error($this->conn); echo "
"; echo $this->hiLightSQL($sql); echo "
"; } $this->result = $result; return ($this->result != false); } function query($sql) { return $this->execQuery($sql); } function selectAll($table, $where = '', $order = '', $limit = '', $field = "") { $where = $where ? ' WHERE ' . $where : ''; $order = $order ? ' ORDER BY ' . $order : ''; $limit = $limit ? ' LIMIT ' . $limit : ''; $field = $field ? $field : '*'; $this->queryCount++; return $this->execQuery("SELECT $field FROM $table $where $order $limit"); } function exists($table, $where = '') { $this->queryCount++; if ($this->result($this->execSQL("SELECT 1 FROM $table " . ($where ? "WHERE $where" : '')), 0) > 0) { return true; } else { return false; } } /* ********** ********** ********** ********** ********** */ function getColumn($table, $field) { $sql = " SELECT $field from $table "; $rs = $this->execSQL($sql); $result = array(); while ($a = $this->fetchAry($rs)) { $result[] = $a[0]; } return $result; } /* ********** ********** ********** ********** ********** */ function countTotal($table, $where = '', $join = '') { $sql = "SELECT COUNT(*) FROM $table " . ($join ? $join : '') . " " . ($where ? "WHERE $where" : ''); if (isset($this->debug) && $this->debug) { echo $sql; } return $this->result($this->execSQL($sql), 0); } /* ********** ********** ********** ********** ********** */ function result($query, $row = 0) { $query = $this->mysqli_result($query, $row); return $query; } /* ********** ********** ********** ********** ********** */ function mysqli_result($res, $row, $field = 0) { $res->data_seek($row); $datarow = $res->fetch_array(); return $datarow[$field]; } /* ********** ********** ********** ********** ********** */ function insertSQL($sql) { if (@mysqli_query($this->conn, $sql)) { return $this->getInsertID(); } else { return 0; } } function getErrMsg() { return @mysqli_error(); } /* ********** ********** ********** ********** ********** */ function execSQL($sql) { $result = @mysqli_query($this->conn, $sql); $DebugMode = ($_SERVER['SERVER_NAME'] == 'localhost' || $_SERVER['SERVER_NAME'] == 'dev.debug' || $_SERVER['SERVER_NAME'] == 'dev.test'); $DebugMode = true; if (mysqli_error($this->conn) && $DebugMode) { echo "
"; echo "SQL Error: "; echo "
"; echo @mysqli_error($this->conn); echo "
"; echo $this->hiLightSQL($sql); echo "
"; } return $result; //return $this->affectedRows(); }/* ********** ********** ********** ********** ********** */ function errorExists() { if (mysqli_error($this->conn)) { return true; } else { return false; } } function beginTrans() { $result = @mysqli_query($this->conn, "SET AUTOCOMMIT=0"); $result = @mysqli_query($this->conn, "BEGIN"); }/* ********** ********** ********** ********** ********** */ function commitTrans() { $result = @mysqli_query($this->conn, "COMMIT"); $result = @mysqli_query($this->conn, "SET AUTOCOMMIT=1"); }/* ********** ********** ********** ********** ********** */ function rollbackTrans() { $result = @mysqli_query($this->conn, "ROLLBACK"); $result = @mysqli_query($this->conn, "SET AUTOCOMMIT=1"); }/* ********** ********** ********** ********** ********** */ function fetchObject() { return (@mysqli_fetch_object($this->result)); } /* ********** ********** ********** ********** ********** */ function fetchObj($rs) { return (@mysqli_fetch_object($rs)); } /* ********** ********** ********** ********** ********** */ function fetchArray() { return (@mysqli_fetch_array($this->result,MYSQLI_ASSOC)); } /* ********** ********** ********** ********** ********** */ function fetchAry($rs) { return (@mysqli_fetch_array($rs,MYSQLI_ASSOC)); } /* ********** ********** ********** ********** ********** */ function recordCount() { return (@mysqli_num_rows($this->result)); } /* ********** ********** ********** ********** ********** */ function recCT($rs) { return (@mysqli_num_rows($rs)); } /* ********** ********** ********** ********** ********** */ function affectedRows() { return (@mysqli_affected_rows($this->conn)); } /* ********** ********** ********** ********** ********** */ /* suitable for auto increment value */ function getInsertID() { return @mysqli_insert_id($this->conn); } /* ********** ********** ********** ********** ********** */ function escapeString($string) { return @mysqli_real_escape_string($this->conn, $string); } /* ********** ********** ********** ********** ********** */ function hiLightSQL($iSQL) { $oSQL = $iSQL; $color1 = 'Blue'; $color2 = 'Magenta'; $color3 = 'Orange'; $color1 = 'MediumOrchid'; $color2 = 'Magenta'; $color3 = 'Purpler'; $oSQL = str_replace('=', '=', $oSQL); $oSQL = str_replace('(', '(', $oSQL); $oSQL = str_replace(')', ')', $oSQL); $oSQL = str_replace('UNION ', '
UNION
', $oSQL); $oSQL = str_replace('SELECT ', 'SELECT ', $oSQL); $oSQL = str_replace('UPDATE ', 'UPDATE ', $oSQL); $oSQL = str_replace('INSERT ', 'INSERT ', $oSQL); $oSQL = str_replace(' SET ', ' SET ', $oSQL); $oSQL = str_replace(' FROM ', '
FROM ', $oSQL); $oSQL = str_replace(' WHERE ', '
WHERE ', $oSQL); $oSQL = str_replace(' ORDER ', '
ORDER ', $oSQL); $oSQL = str_replace(' GROUP ', '
GROUP ', $oSQL); $oSQL = str_replace(' BY ', ' BY ', $oSQL); $oSQL = str_replace(' LEFT ', '
LEFT ', $oSQL); $oSQL = str_replace(' RIGHT ', '
RIGHT ', $oSQL); $oSQL = str_replace(' OUTER ', ' OUTER ', $oSQL); $oSQL = str_replace(' INNER ', ' INNER ', $oSQL); $oSQL = str_replace(' JOIN ', ' JOIN ', $oSQL); $oSQL = str_replace(' IS ', ' IS ', $oSQL); $oSQL = str_replace(' NULL ', ' NULL ', $oSQL); $oSQL = str_replace(' ON ', ' ON ', $oSQL); $oSQL = str_replace(' AND ', ' AND ', $oSQL); $oSQL = str_replace(' OR ', ' OR ', $oSQL); $oSQL = str_replace(' LIMIT ', '
LIMIT ', $oSQL); $oSQL = str_replace(' BETWEEN ', ' BETWEEN ', $oSQL); $oSQL = str_replace(' AS ', ' AS ', $oSQL); $oSQL = str_replace(' NOT ', ' NOT ', $oSQL); $oSQL = str_replace(' IN ', ' IN ', $oSQL); $oSQL = str_replace(' RAND<', ' RAND<', $oSQL); $oSQL = str_replace(' CONCAT', ' CONCAT', $oSQL); $oSQL = str_replace(' COALESCE', ' COALESCE', $oSQL); $oSQL = str_replace(' SUBSTRING', ' SUBSTRING', $oSQL); return $oSQL; } /* hiLightSQL*/ /* ********** ********** ********** ********** ********** */ } } /* clsMySQL */ /* ********** ********** ********** ********** ********** ********** ********** ********** ********** ********** */ ?>