Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class DatabaseException extends Exception { }
- final class core {
- public static $database = null;
- public static $user = null;
- public static function getUser() {
- if(empty(self::$user) || self::$user === null) self::$user = new user();
- return self::$user;
- }
- public static function getDatabase() {
- $dsn = 'mysql:dbname=' . config::$mysql['database'] . ';host=' . config::$mysql['host'];
- try {
- self::$database = new PDO($dsn, config::$mysql['user'], config::$mysql['pass']);
- self::$database->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- } catch (PDOException $e) {
- throw new DatabaseException($e->getMessage());
- //exit;
- }
- return self::$database;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement