Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Database{
- private static $dbName = 'snort' ;
- private static $dbHost = '192.168.180.129:3306' ;
- private static $dbUser = 'snort';
- private static $dbPass = 'snortpass';
- private static $cont = null;
- public function __construct() {
- die('This is static class, so you cannot initiate object of that class.');
- }
- public static function connect(){
- if ( null == self::$cont ){
- try
- {
- self::$cont = new PDO( "mysql:host=".self::$dbHost.";"."dbname=".self::$dbName, self::$dbUser, self::$dbPass);
- }
- catch(PDOException $e)
- {
- die($e->getMessage());
- }
- }
- return self::$cont;
- }
- public static function disconnect()
- {
- self::$cont = null;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement