Advertisement
Guest User

Untitled

a guest
Jan 21st, 2019
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.80 KB | None | 0 0
  1. <?php
  2.     include('IDataService.php');
  3.     class DataService implements IDataService {
  4.       var $conn;
  5.  
  6.       public function __construct($host, $user, $pass, $db) {
  7.           $conn = mysqli_connect($host, $user, $pass, $db);
  8.           if(!$conn) {
  9.               throw new Exception("A database connection could not be made.");
  10.           }
  11.       }
  12.  
  13.       public function GetMovies($id) {
  14.             return $this->conn->query("SELECT * FROM movie WHERE catNo = $id")->fetch_array();
  15.       }
  16.  
  17.       public function GetCategories() {
  18.             return $this->conn->query("SELECT * FROM category")->fetch_array();
  19.       }
  20.  
  21.       public function GetCategoryName($id) {
  22.             return $this->conn->query("SELECT catName FROM category WHERE catNo = $id")->fetch_assoc()["catName"];
  23.       }
  24.     }
  25. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement