Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Description of Conexion
- *
- * @author Docente
- */
- class Conexion {
- // Implementación de Singleton
- private static $instancia = null;
- public function __construct()
- {
- try {
- self::$instancia = new PDO('mysql:host=localhost;dbname=limapass','root', 'xlujiax147');
- self::$instancia->exec("SET CHARACTER SET utf8");
- } catch (PDOException $e) {
- print "Error!: " . $e->getMessage();
- die();
- }
- }
- public static function singleton()
- {
- if (!isset(self::$instancia)) {
- $miclase = __CLASS__;
- self::$instancia = new $miclase;
- }
- return self::$instancia;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement