Code : Tout sélectionner
<?php
define ("DB_DNS", "mysql:host=localhost;dbname=dccc");
class mysql extends PDO {
private static $_instance;
/* Constructeur : héritage public obligatoire par héritage de PDO */
public function __construct( ) {
}
// End of PDO2::__construct() */
/* Singleton */
public static function getInstance() {
if (!isset(self::$_instance)) {
try {
self::$_instance = new PDO(DB_DNS, 'xxx', 'bxxxx');
} catch (PDOException $e) {
die($e);
}
}
return self::$_instance;
}
// End of PDO2::getInstance() */
}
?>