Advertisement
Guest User

Untitled

a guest
Jun 27th, 2016
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. <?php
  2. class DBController {
  3. private $host = "localhost";
  4. private $user = "root";
  5. private $password = "root";
  6. private $database = "tblproduct";
  7.  
  8. function __construct() {
  9. $conn = $this->connectDB();
  10. if(!empty($conn)) {
  11. $this->selectDB($conn);
  12. }
  13. }
  14.  
  15. function connectDB() {
  16.  
  17. $conn = mysqli_connect($this->host,$this->user,$this->password);
  18. return $conn;
  19. }
  20.  
  21. function selectDB($conn) {
  22. mysqli_select_db($conn,$this->database);
  23. }
  24.  
  25. function runQuery($query) {
  26.  
  27. $result = mysqli_query($this->database->query($query)) or die("It's not connecting");
  28. while($row=mysqli_fetch_assoc($result)) {
  29. $resultset[] = $row;
  30. }
  31. if(!empty($resultset))
  32. return $resultset;
  33. }
  34.  
  35. function numRows($query) {
  36. $result = mysqli_query($query);
  37. $rowcount = mysqli_num_rows($result);
  38. return $rowcount;
  39. }
  40. }
  41. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement