Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Database
- {
- private $host = DB_HOST;
- private $user = DB_USER;
- private $password = DB_PASSWORD;
- private $dbname = DB_NAME;
- private $connection;
- private $error;
- public function __construct()
- {
- $this->connectToDB();
- }
- // Connect to Database
- private function connectToDB()
- {
- $this->connection = new mysqli($this->host, $this->user, $this->password, $this->dbname);
- if (!$this->connection) {
- $this->error = "Conection failed" . $this->connectToDB->connect_error;
- return false;
- }
- }
- // Read Data
- public function select($query)
- {
- $result = $this->link->query($query) or die($this->link->error . __LINE__);
- if ($result->mysqli_num_rows > 0) {
- return $result;
- } else {
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement