Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Database
- {
- private $connect;
- private $host, $username, $password, $databaseName;
- public function __construct($host, $username, $password, $databaseName)
- {
- $this->host = $host;
- $this->username = $username;
- $this->password = $password;
- $this->databaseName = $databaseName;
- $this->connect = new mysqli($this->host, $this->username, $this->password, $this->databaseName);
- if ($this->connect->connect_error) {
- die('Connect Error (' . $this->connect->connect_errno . ') '. $this->connect->connect_error);
- }
- return true;
- }
- public function __destruct()
- {
- $this->connect->close();
- }
- }
- $db = new Database("localhost", "root", "", "framework");
- class Members extends Database {
- public function getMembers() {
- $result = $this->connect->query("SELECT * FROM members");
- return $query->row;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement