Advertisement
Guest User

query.php

a guest
Feb 8th, 2019
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.68 KB | None | 0 0
  1. <?php
  2.  
  3. require 'koneksi.php';
  4.  
  5. class Query extends Connect{
  6.  
  7.     protected $sql;
  8.     protected $result;
  9.  
  10.     public function SQLLogin($username, $password){
  11.         // Nantinya akan saya gunakan pada proses login users.
  12.         $this->sql = "SELECT * FROM tb_login WHERE username = '".$username."' AND password = '".$password."'";
  13.         // Memanggil method getResult untuk mengeksekusi sintaks SQL.
  14.         return $this->getResult();
  15.     }
  16.  
  17.     public function SQLValidateEmail($username){
  18.         // Nantinya saya akan gunakan untuk proses validasi email pada proses register
  19.         $this->sql = "SELECT * FROM tb_cs WHERE id_cs = '".$id_cs."'";
  20.         // Memanggil method getResult untuk mengeksekusi sintaks SQL.
  21.         return $this->getResult();
  22.     }
  23.  
  24.     public function SQLRegister($id_cs, $nm_cs, $keluhan){
  25.         // Nantinya saya akan gunakan untuk proses register user
  26.         $this->sql = "INSERT INTO tb_cs(id_cs, nm_cs, keluhan)"."VALUES ('".$id_cs."', '".$nm_cs."', '".$keluhan."', NOW())";
  27.         // Memanggil method getResult untuk mengeksekusi sintaks SQL.
  28.         return $this->getResult();
  29.     }
  30.     public function read(){
  31.     $sql = "SELECT * FROM tb_kerusakan ORDER BY nama_kerusakan ASC";
  32.     $hasil = mysqli_query($this->connection, $sql);
  33.     while ($row = mysqli_fetch_assoc($hasil)) {
  34.         $hasil [] = $row;
  35.    
  36.     }
  37.     return $hasil;
  38. }
  39.     public function getResult(){
  40.         // Setelah method SQL diatas di panggil setelah itu method getResult akan dipanggil untuk mengeksekusi
  41.         // sintaks SQL diatas.
  42.         $this->result = $this->dbConn()->query($this->sql);
  43.         return $this;
  44.     }
  45.  
  46.     public function FetchArray(){
  47.         // Method ini berfungsi untuk memasukan data yang berada pada database kedalam variable array.
  48.         $row = $this->result->fetch_array();
  49.         return $row;
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement