Advertisement
Guest User

Untitled

a guest
Mar 12th, 2016
68
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 database {
  3. private $host = "";
  4. private $user = "";
  5. private $password = "";
  6. private $database = "";
  7.  
  8. function __construct() {
  9. $conn = $this->connectDB();
  10. if(!empty($conn)) {
  11. $this->selectDB($conn);
  12. }
  13. }
  14.  
  15. function connectDB() {
  16. $conn = new mysqli("", "", "", "");
  17. return $conn;
  18. }
  19.  
  20. function selectDB($conn) {
  21. new 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