Last active
October 2, 2018 07:24
-
-
Save Ajax30/951ba4d63746d5b3529221ec9e614ec5 to your computer and use it in GitHub Desktop.
Database class mysqli object oriented
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Database | |
{ | |
public $host = DB_HOST; | |
public $username = DB_USER; | |
public $password = DB_PASS; | |
public $dbname = DB_NAME; | |
public $link; | |
public $error; | |
/* Constructor */ | |
public function __construct() | |
{ | |
$this->connect(); | |
} | |
/* Conector */ | |
private function connect() | |
{ | |
$this->link = new mysqli($this->host, $this->username, $this->password, $this->dbname); | |
if (!$this->link) { | |
$this->error = "Failed to connect: " . $this->link->connect_error; | |
return false; | |
} | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment