aakash2310

Untitled

Oct 3rd, 2022
43
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. {
  4. private $host = "localhost";
  5. private $user = "root";
  6. private $password = "";
  7. private $database = "dbtry";
  8. private $conn;
  9. function __construct()
  10. {
  11. $this->conn = $this->connectDB();
  12. }
  13. function connectDB()
  14. {
  15. $conn = mysqli_connect($this->host,$this->user,$this->password,$this->database);
  16. return $conn;
  17. }
  18. function runQuery($query)
  19. {
  20. $result = mysqli_query($this->conn,$query);
  21. while($row=mysqli_fetch_assoc($result))
  22. {
  23. $resultset[] = $row;
  24. }
  25. if(!empty($resultset))
  26. return $resultset;
  27. }
  28.  
  29. function numRows($query)
  30. {
  31. $result = mysqli_query($this->conn,$query);
  32. $rowcount = mysqli_num_rows($result);
  33. return $rowcount;
  34. }
  35. }
  36. ?>
Advertisement
Add Comment
Please, Sign In to add comment