Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Database Class - PHP
<?php
class Database {
public static $conn;
public static function connect(){
try {
$conn = new PDO(DB_DRIVER.':host='.DB_HOST.';dbname='.DB_NAME.';', DB_USER, DB_PASSWORD);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
self::$conn = $conn;
} catch (PDOException $e) {
$e->getMessage();
}
}
}
//Construct
Database::connect();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment