Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class DB {
- private static $singleton;
- private $connection;
- private $DB_USERNAME = "root";
- private $DB_PASSWORD = "root"; //Yours should be empty
- private $DB_HOST = "localhost";
- private function __construct() {
- $this->connection = new PDO(
- "mysql:host=$this->DB_HOST;dbname=bookapp",
- $this->DB_USERNAME,
- $this->DB_PASSWORD
- );
- $this->connection->exec("SET CHARACTER SET utf8");
- }
- public static function getInstance() {
- if (is_null(self::$singleton)) {
- self::$singleton = new DB();
- }
- return self::$singleton;
- }
- public function getHandler() {
- return $this->connection;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement