Guest User

fefe

a guest
Sep 4th, 2018
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. <?php
  2.  
  3. class DBController {
  4. private $conn = "";
  5. private $host = "localhost";
  6. private $user = "root";
  7. private $password = "Efr;
  8. private $database = "pufrfr
  9.  
  10. function __construct() {
  11. $conn = $this->connectDB();
  12. if(!empty($conn)) {
  13. $this->conn = $conn;
  14. }
  15. }
  16.  
  17. function connectDB() {
  18. $conn = mysqli_connect($this->host,$this->user,$this->password,$this->database);
  19. return $conn;
  20. }
  21.  
  22. function runSelectQuery($query) {
  23. $result = mysqli_query($this->conn,$query);
  24. while($row=@mysqli_fetch_assoc($result)) {
  25. $resultset[] = $row;
  26. }
  27. if(!empty($resultset))
  28. return $resultset;
  29. }
  30. function runSelectQuerys($query) {
  31. $result = mysqli_query($this->conn,$query);
  32. while($row=@mysqli_fetch_assoc($result)) {
  33. $resultset[] = $row;
  34. }
  35. if(!empty($resultset))
  36. return $resultset[0];
  37. }
  38. function executeInsert($query) {
  39. //echo $query;die;
  40. $result = mysqli_query($this->conn,$query);
  41. $insert_id = mysqli_insert_id($this->conn);
  42. return $insert_id;
  43.  
  44. }
  45. function executeUpdate($query) {
  46. $result = mysqli_query($this->conn,$query);
  47. return $result;
  48.  
  49. }
  50.  
  51. function executeQuery($sql) {
  52. $result = mysqli_query($this->conn,$sql);
  53. return $result;
  54.  
  55. }
  56.  
  57. function numRows($query) {
  58. $result = mysqli_query($this->conn,$query);
  59. $rowcount = mysqli_num_rows($result);
  60. return $rowcount;
  61. }
  62. }
  63. ?>
Add Comment
Please, Sign In to add comment