Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Database
- {
- /**
- * Déclarations variables connexion à la base de données
- */
- private static $dbhost = "localhost";
- private static $dbName = "france";
- private static $dbUsername = "root";
- private static $dbUserPassword = "";
- private static $connection = NULL;
- public static function connect() {
- if (self::$connection == NULL) {
- try {
- self::$connection = new PDO("mysql:host=" . self::$dbhost . "; dbName =" . self::$dbName, self::$dbUsername, self::$dbUserPassword);
- self::$connection -> setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- }
- catch (PDOException $e) {
- die($e -> getMessage());
- }
- }
- return self::$connection;
- }
- public static function disconnect() {
- self::$connection = NULL;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement