Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class DBGame {
- private $username = "root";
- private $password = "";
- private $db = "rev_game";
- private $host = "localhost";
- private $mysqli;
- public $con;
- public function connect() {
- $this->mysqli = new mysqli($this->host, $this->username, $this->password, $this->db);
- }
- public function close() {
- mysqli_close($this->mysqli);
- }
- public function createGame($nama, $category, $sinopsis, $cpu, $ram, $os, $gpu) {
- $this->mysqli->query("INSERT INTO game (nama, category, sinopsis) VALUES ('$nama', '$category', '$sinopsis')");
- $this->mysqli->query("INSERT INTO spec (CPU, RAM, OS, GPU, idGame) SELECT '$cpu','$ram','$os', '$gpu', game.idGame FROM game WHERE game.nama = '$nama' ");
- $idGuame = $this->mysqli->query("SELECT * FROM game WHERE nama = '$nama'");
- return $idGuame;
- // $this->mysqli->query("INSERT INTO preview (directory, idGame) SELECT '$trailer', game.idGame FROM game WHERE game.nama = '$nama' ");
- // $this->mysqli->query("INSERT INTO preview (directory, idGame) SELECT '$ss', game.idGame FROM game WHERE game.nama = '$nama' ");
- }
- public function createPrevHead($idGame, $trailer, $ss, $head) {
- $this->mysqli->query("INSERT INTO preview (directory, idGame, type) VALUES ('$trailer', '$idGame', 1)");
- $this->mysqli->query("INSERT INTO preview (directory, idGame, type) VALUES ('$ss', '$idGame', 0)");
- $this->mysqli->query("INSERT INTO header (directory, idGame) VALUES ('$head', '$idGame')");
- }
- public function fetchData($idGame) {
- $dataGame = $this->mysqli->query("select * from `game` where game.idGame = $idGame");
- return $dataGame;
- }
- public function fetchDataHeader($idGame) {
- $dataGame = $this->mysqli->query("select * from game join header on game.idGame = header.idGame where game.idGame = $idGame");
- return $dataGame;
- }
- public function fetchDataSpec($idGame) {
- $dataSpec = $this->mysqli->query("select * from spec where spec.idGame = $idGame");
- return $dataSpec;
- }
- public function fetchDataSlider($idGame) {
- $dataSlider = $this->mysqli->query("SELECT * FROM preview WHERE preview.idGame = $idGame AND preview.type = 0");
- return $dataSlider;
- }
- public function fetchDataVideo($idGame) {
- $dataVideo = $this->mysqli->query("SELECT * FROM preview WHERE preview.idGame = $idGame AND preview.type = 1");
- return $dataVideo;
- }
- public function fetchDataSearch($sCari, $kategori) {
- $dataSearch = $this->mysqli->query("select * from game where nama=$sCari and category=$kategori");
- return $dataSearch;
- }
- public function cekRev($idMember, $idGame) {
- $dataCek = $this->mysqli->query("select count(*) from review where idGame='$idGame' and idMember = '$idMember'");
- return $dataCek;
- }
- public function saveReview($idMember, $idGame, $isi) {
- $this->mysqli->query("insert into review (isi, idMember, idGame) values ('$isi','$idMember','$idGame')");
- }
- public function fetchNewAdd() {
- $dataNew = $this->mysqli->query("SELECT * FROM game join header on game.idGame= header.idGame order BY game.idGame DESC Limit 5");
- return $dataNew;
- }
- public function fetchHot() {
- $dataHot = $this->mysqli->query("select * from game join header on game.idGame=header.idGame order by view desc limit 5");
- return $dataHot;
- }
- public function fetchTopEach() {
- $data = $this->mysqli->query("SELECT *, MAX(rating) FROM game join header on game.idGame=header.idGame GROUP BY `category`");
- return $data;
- }
- public function fetchTopRated() {
- $dataTop = $this->mysqli->query("select * from game join header on game.idGame=header.idGame order by rating desc limit 3");
- return $dataTop;
- }
- public function fetchNewRev() {
- $dataNewRev = $this->mysqli->query("SELECT * from member join review on member.idMember=review.idMember JOIN game on review.idGame=game.idGame ORDER BY idReview DESC LIMIT 5");
- return $dataNewRev;
- }
- public function getAllGames() {
- $dataNewRev = $this->mysqli->query("select * from game join header on game.idGame=header.idGame");
- return $dataNewRev;
- }
- public function getCatGames($kategori) {
- $dataNewRev = $this->mysqli->query("select * from game join header on game.idGame=header.idGame where category='$kategori'");
- return $dataNewRev;
- }
- public function getTheGame($string, $kategori) {
- // $dataNewRev = $this->mysqli->query("select * from game join header on game.idGame=header.idGame where category='$kategori' and nama='$string'");
- $dataNewRev = $this->mysqli->query("SELECT * FROM game JOIN header ON game.idGame=header.idGame WHERE category='$kategori' AND LOCATE('$string', nama) NOT LIKE 0");
- return $dataNewRev;
- }
- public function getGame($string, $kategori) {
- $dataGame = $this->mysqli->query("SELECT * FROM game JOIN header ON game.idGame=header.idGame WHERE locate('$string', nama) NOT LIKE 0");
- return $dataGame;
- }
- //Mas ali
- function execute($query) {
- $con = mysqli_connect("localhost", "root", "", "rev_game");
- return mysqli_query($con, $query);
- }
- function updateRating($hasil, $idGame, $dataMemberBaru, $hasilRating) {
- $query = "update game set rating='$hasilRating', MemberMerating='$dataMemberBaru', totalRating='$hasil' where idGame='$idGame'";
- return $this->execute($query);
- }
- function lihatGame($idGame) {
- $query = "select * from game where idGame='$idGame'";
- return $this->execute($query);
- }
- function fetch($var) {
- return mysqli_fetch_array($var);
- }
- function fetchDataReview($idGame) {
- $data = $this->mysqli->query("SELECT * FROM `review` JOIN member on review.idMember=member.idMember WHERE review.idGame = $idGame");
- return $data;
- }
- public function deleteGame($idGame) {
- $query = "delete from game where idGame='$idGame'";
- $query2 = "delete from header where idGame='$idGame'";
- $query3 = "delete from preview where idGame='$idGame'";
- $query4 = "delete from review where idGame='$idGame'";
- $query5 = "delete from spec where idGame='$idGame'";
- $this->mysqli->query($query);
- $this->mysqli->query($query2);
- $this->mysqli->query($query3);
- $this->mysqli->query($query4);
- $this->mysqli->query($query5);
- }
- public function insertReview($eReview, $idGame, $idMember) {
- $idMem = $idGame;
- $idG = $idMember;
- $this->mysqli->query("UPDATE `review` SET isi ='$eReview' WHERE `idMember` ='$idMem' and `idGame` ='$idG'");
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement