projet_php/config/database.php
Yasder5 28f57e9835 ça commence doucement
hehehe c b1 de kodé
2026-01-13 22:21:32 +01:00

23 lines
No EOL
713 B
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
class Connect {
protected $_db;
public function __construct(){
try{
// Connexion à la base de données
$this->_db = new PDO(
"mysql:host=localhost;dbname=projet_folliow", // Serveur et BDD
"root", //Nom d'utilisateur de la base de données
"",// Mot de passe de la base de données
array(PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC) // Mode de renvoi
);
// Pour résoudre les problèmes dencodage
$this->_db->exec("SET CHARACTER SET utf8");
// Configuration des exceptions
$this->_db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch(PDOException$e) {
echo "Échec : " . $e->getMessage();
}
}
}