Skip to content

Instantly share code, notes, and snippets.

@aranajhonny
Created April 19, 2016 16:42
Show Gist options
  • Save aranajhonny/52389c15de1f787b5545a179db004fa0 to your computer and use it in GitHub Desktop.
Save aranajhonny/52389c15de1f787b5545a179db004fa0 to your computer and use it in GitHub Desktop.
<?php
class Db {
private static $instance = NULL;
private function __construct() {}
public static function getInstance() {
if (!isset(self::$instance)) {
$pdo_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION;
self::$instance = new PDO('mysql:host=localhost;dbname=php_mvc', 'root', 'root', $pdo_options);
}
return self::$instance;
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment