SHARE
TWEET

Untitled

a guest Dec 29th, 2016 110 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. class Database{
  3.     private static $dbName = 'snort' ;
  4.     private static $dbHost = '192.168.180.129:3306' ;
  5.     private static $dbUser = 'snort';
  6.     private static $dbPass = 'snortpass';
  7.      
  8.     private static $cont  = null;
  9.      
  10.     public function __construct() {
  11.         die('This is static class, so you cannot initiate object of that class.');
  12.     }
  13.      
  14.     public static function connect(){
  15.         if ( null == self::$cont ){    
  16.             try
  17.             {
  18.               self::$cont =  new PDO( "mysql:host=".self::$dbHost.";"."dbname=".self::$dbName, self::$dbUser, self::$dbPass);
  19.             }
  20.             catch(PDOException $e)
  21.             {
  22.               die($e->getMessage());
  23.             }
  24.         }
  25.         return self::$cont;
  26.     }
  27.      
  28.     public static function disconnect()
  29.     {
  30.         self::$cont = null;
  31.     }
  32. }
  33. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top