Advertisement
Guest User

Untitled

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