From f2f0ee96f0b1f77c8a5d082d5e140324775bdaa9 Mon Sep 17 00:00:00 2001 From: Florian SYLVAIN Date: Fri, 24 Sep 2021 11:51:27 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Adding=20conf.php=20class=20to?= =?UTF-8?q?=20create=20PDO=20exclusively=20from=20this.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ProjetProgWeb/class/conf.php | 15 +++++++++++++++ ProjetProgWeb/class/dump.php | 7 +++++-- ProjetProgWeb/conf.php | 3 --- ProjetProgWeb/scripts/extract.php | 1 - 4 files changed, 20 insertions(+), 6 deletions(-) create mode 100644 ProjetProgWeb/class/conf.php delete mode 100644 ProjetProgWeb/conf.php diff --git a/ProjetProgWeb/class/conf.php b/ProjetProgWeb/class/conf.php new file mode 100644 index 0000000..0e7448a --- /dev/null +++ b/ProjetProgWeb/class/conf.php @@ -0,0 +1,15 @@ +pdo = new PDO('mysql:host=localhost;dbname=projet_prog_web', 'root', 'root'); + } + + public function getPDO() : pdo { + return $this->pdo; + } +} \ No newline at end of file diff --git a/ProjetProgWeb/class/dump.php b/ProjetProgWeb/class/dump.php index 902bbe0..361f113 100644 --- a/ProjetProgWeb/class/dump.php +++ b/ProjetProgWeb/class/dump.php @@ -1,6 +1,7 @@ getPDO(); $stmt = $pdo->query("SELECT * FROM theses WHERE author = '$author';"); $i = 0; while ($obj = $stmt->fetchObject()) { @@ -54,7 +56,8 @@ class dump { 'date_update' => empty($this->these->getDateUpdate()) ? NULL : $this->these->getDateUpdate() ]; $sql = "INSERT INTO theses (author, id_author, these_director, title, these_director_name_lastname, id_director, soutenance_establishment, id_establishment, discipline, status, date_first_registration, date_soutenance, language, id_these, online, date_publication, date_update) VALUES (:author, :id_author, :these_director, :title, :these_director_name_lastname, :id_director, :soutenance_establishment, :id_establishment, :discipline, :status, :date_first_registration, :date_soutenance, :language, :id_these, :online, :date_publication, :date_update)"; - $pdo = new PDO('mysql:host=localhost;dbname=projet_prog_web', 'root', 'root'); + $pdo_obj = new conf(); + $pdo = $pdo_obj->getPDO(); $stmt= $pdo->prepare($sql); $stmt->execute($data); } diff --git a/ProjetProgWeb/conf.php b/ProjetProgWeb/conf.php deleted file mode 100644 index 7564d0b..0000000 --- a/ProjetProgWeb/conf.php +++ /dev/null @@ -1,3 +0,0 @@ -