Created
February 19, 2016 13:05
-
-
Save TheDutchDev/2ebd812ba1c09911b9f3 to your computer and use it in GitHub Desktop.
PHP Database OOP
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
class Database | |
{ | |
private | |
$database, | |
$dbhost = '', // usually localhost | |
$dbname = '', | |
$dbuser = '', | |
$dbpass = '' | |
; | |
public function __construct( ) | |
{ | |
$this->database = new mysqli( $this->dbhost, $this->dbuser, $this->dbpass, $this->dbname ); | |
if( $this->database->connect_errno) | |
{ | |
die( "Failed to connect to MySQL: (" . $this->database->connect_errno . ") " . $this->database->connect_error ); | |
} | |
} | |
function get_connection( ) | |
{ | |
return $this->database; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment