Skip to content

Instantly share code, notes, and snippets.

@Ajax30
Last active October 2, 2018 07:24
Show Gist options
  • Save Ajax30/951ba4d63746d5b3529221ec9e614ec5 to your computer and use it in GitHub Desktop.
Save Ajax30/951ba4d63746d5b3529221ec9e614ec5 to your computer and use it in GitHub Desktop.
Database class mysqli object oriented
<?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