Advertisement
Guest User

Untitled

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