SHARE
TWEET

Conexion

xlujiax Dec 3rd, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. /**
  3.  * Description of Conexion
  4.  *
  5.  * @author Docente
  6.  */
  7. class Conexion {
  8.             // Implementaci√≥n de Singleton
  9.     private static $instancia = null;
  10.     public function __construct()
  11.     {
  12.         try {
  13.             self::$instancia = new PDO('mysql:host=localhost;dbname=limapass','root', 'xlujiax147');
  14.             self::$instancia->exec("SET CHARACTER SET utf8");
  15.         } catch (PDOException $e) {
  16.             print "Error!: " . $e->getMessage();
  17.             die();
  18.         }          
  19.     }
  20.     public static function singleton()
  21.     {
  22.         if (!isset(self::$instancia)) {
  23.             $miclase = __CLASS__;
  24.             self::$instancia = new $miclase;
  25.         }
  26.         return self::$instancia;
  27.     }
  28. }
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