Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- abstract class Database
- {
- private static $dbName = 'hanka' ;
- private static $dbHost = 'localhost' ;
- private static $dbUsername = 'hanka';
- private static $dbUserPassword = 'vozQWvN2N';
- private static $cont = null;
- public function __construct() {
- die('Funkcja Init function nie jest dozwolona');
- }
- public static function connect()
- {
- // Jedno połaczenie za pośrednictwem aplikacji
- if ( null == self::$cont )
- {
- try
- {
- self::$cont = new PDO( "mysql:host=".self::$dbHost.";"."dbname=".self::$dbName, self::$dbUsername, self::$dbUserPassword);
- }
- 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