Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Banco
- {
- private static $dbNome = '';
- private static $dbHost = '';
- private static $dbUsuario = '';
- private static $dbSenha = '';
- private static $cont = null;
- public function __construct()
- {
- die('A função Init nao é permitido!');
- }
- public static function conectar()
- {
- if(null == self::$cont)
- {
- try
- {
- self::$cont = new PDO( "mysql:host=".self::$dbHost.";"."dbname=".self::$dbNome, self::$dbUsuario, self::$dbSenha);
- }
- catch(PDOException $exception)
- {
- die($exception->getMessage());
- }
- }
- return self::$cont;
- }
- public static function desconectar()
- {
- self::$cont = null;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement