Advertisement
Guest User

Untitled

a guest
Dec 11th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. <?php
  2. class Database
  3. {
  4. private $connect;
  5. private $host, $username, $password, $databaseName;
  6.  
  7. public function __construct($host, $username, $password, $databaseName)
  8. {
  9. $this->host = $host;
  10. $this->username = $username;
  11. $this->password = $password;
  12. $this->databaseName = $databaseName;
  13.  
  14. $this->connect = new mysqli($this->host, $this->username, $this->password, $this->databaseName);
  15.  
  16. if ($this->connect->connect_error) {
  17. die('Connect Error (' . $this->connect->connect_errno . ') '. $this->connect->connect_error);
  18. }
  19.  
  20. return true;
  21. }
  22.  
  23. public function __destruct()
  24. {
  25. $this->connect->close();
  26. }
  27. }
  28.  
  29. $db = new Database("localhost", "root", "", "framework");
  30.  
  31. class Members extends Database {
  32. public function getMembers() {
  33. $result = $this->connect->query("SELECT * FROM members");
  34. return $query->row;
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement