Created
June 23, 2015 11:21
-
-
Save praswicaksono/9e3b69044d29060f959a to your computer and use it in GitHub Desktop.
singleton
This file contains hidden or 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 | |
| { | |
| /** | |
| * @var \PDO | |
| */ | |
| protected static $conn; | |
| /** | |
| * @return \PDO | |
| */ | |
| public static function getDB() | |
| { | |
| if (! self::$conn instanceof \PDO) { | |
| self::$conn = new \PDO(); | |
| } | |
| return self::$conn; | |
| } | |
| } | |
| $conn = Database::getDB(); | |
| $conn->query("blo bla bla"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment