diff --git a/Database/bdd.sql b/Database/bdd.sql index f8a1547..6bf09ef 100644 --- a/Database/bdd.sql +++ b/Database/bdd.sql @@ -4,9 +4,8 @@ -- > Le jeu de caractères utilisé est utf8. -- ===================================================================================================== -- set names 'utf8'; -DROP DATABASE IF EXISTS bdgsb; -CREATE DATABASE `bdgsb` CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; -USE bdgsb; +Drop database if exists gsbbdcr; +USE gsbbdcr; -- ---------------------------------------------------------------------------------------------- create table FAMILLE(fCode VARCHAR(3) not null,fLibelle VARCHAR(83),primary key(fCode)) ENGINE=INNODB DEFAULT CHARSET=utf8; -- @@ -22,7 +21,7 @@ create table TYPE_PRATICIEN(tCode VARCHAR(2) not null,tLibelle VARCHAR(31),tLieu -- create table VISITEUR(vNum INT NOT NULL, vNom VARCHAR(25), vPrenom VARCHAR(25), vIdentifiant VARCHAR(30), vMdp VARCHAR(20), PRIMARY KEY (vNum)) ENGINE=INNODB DEFAULT CHARSET=utf8; -- -create table AVIS(aCode INT AUTO_INCREMENT, mDepotLegal VARCHAR(10) NOT NULL, aAuteur INT NOT NULL, aContenu TEXT NOT NULL, aDate DATE DEFAULT CURRENT_DATE, PRIMARY KEY (aCode)) ENGINE=INNODB DEFAULT CHARSET=utf8; +create table AVIS(aCode INT AUTO_INCREMENT, mDepotLegal VARCHAR(10) NOT NULL, aAuteur INT NOT NULL, aContenu TEXT NOT NULL, aDate DATE, PRIMARY KEY (aCode)) ENGINE=INNODB DEFAULT CHARSET=utf8; -- create table VISITE(visiteId int not null, visiteDate date, visiteMotif varchar(50), visiteCompteRendu varchar(1200), dateCompteRendu DATE, praticienNum int not null, visiteurNum int, depotLegal1 varchar(10), depotLegal2 varchar(10), primary key(visiteId)) ENGINE=INNODB DEFAULT CHARSET=utf8; -- ---------------------------------------------------------------------------------------------- diff --git a/Database/connexionBdd.php b/Database/connexionBdd.php new file mode 100644 index 0000000..97b7236 --- /dev/null +++ b/Database/connexionBdd.php @@ -0,0 +1,39 @@ +creerConnexion($this->ip, $this->database, $this->user, $this->pass); + } + + private function creerConnexion($serveur , $bdd , $nomUtilisateur , $motPasse) { + // Définition de la source des données pour PDO + $dsn = "mysql:host=$serveur;dbname=$bdd;charset=utf8mb4"; + // Création de l'objet $dbh, de type PDO, qui est la ressource d'accès à la base + try { + $dbh = new PDO($dsn, $nomUtilisateur, $motPasse); + } + catch (PDOException $e) { + die("Erreur de connexion : ".$e->getMessage()); + } + } + + public static function getInstance(){ + if(self::$instance == null) + { + echo "Bonjour"; + self::$instance = new connexionSQL(); + } + return self::$instance; + } +} + diff --git a/Database/database.cfg b/Database/database.cfg index cebcd0e..d642387 100644 --- a/Database/database.cfg +++ b/Database/database.cfg @@ -1,8 +1,12 @@ ;Connexion base de données - - - +[databaseServer] +driver = "mysql" +dbHost = "localhost" +dbName = "bdgsb" +charset = "utf8mb4" +username = "root" +passwd = "root" diff --git a/Modele/connexionBdd.php b/Modele/connexionBdd.php deleted file mode 100644 index e69de29..0000000 diff --git a/Tests/test.php b/Tests/test.php index e69de29..8d1d0d5 100644 --- a/Tests/test.php +++ b/Tests/test.php @@ -0,0 +1,5 @@ +