mirror of
https://github.com/Floriansylvain/projet_programmation_web.git
synced 2026-08-19 19:53:18 +02:00
🎨 Adding conf.php class to create PDO exclusively from this.
This commit is contained in:
@@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class conf
|
||||||
|
{
|
||||||
|
private pdo $pdo;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->pdo = new PDO('mysql:host=localhost;dbname=projet_prog_web', 'root', 'root');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPDO() : pdo {
|
||||||
|
return $this->pdo;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once("these.php");
|
require_once("these.php");
|
||||||
|
require_once("conf.php");
|
||||||
|
|
||||||
class dump {
|
class dump {
|
||||||
private these $these;
|
private these $these;
|
||||||
@@ -19,7 +20,8 @@ class dump {
|
|||||||
public static function getTheseByAuthor($author) : array {
|
public static function getTheseByAuthor($author) : array {
|
||||||
$theses_array = [];
|
$theses_array = [];
|
||||||
|
|
||||||
$pdo = new PDO('mysql:host=localhost;dbname=projet_prog_web;charset=utf8', 'root', 'root');
|
$pdo_obj = new conf();
|
||||||
|
$pdo = $pdo_obj->getPDO();
|
||||||
$stmt = $pdo->query("SELECT * FROM theses WHERE author = '$author';");
|
$stmt = $pdo->query("SELECT * FROM theses WHERE author = '$author';");
|
||||||
$i = 0;
|
$i = 0;
|
||||||
while ($obj = $stmt->fetchObject()) {
|
while ($obj = $stmt->fetchObject()) {
|
||||||
@@ -54,7 +56,8 @@ class dump {
|
|||||||
'date_update' => empty($this->these->getDateUpdate()) ? NULL : $this->these->getDateUpdate()
|
'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)";
|
$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= $pdo->prepare($sql);
|
||||||
$stmt->execute($data);
|
$stmt->execute($data);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
$pdo = new PDO('mysql:host=localhost;dbname=projet_prog_web', 'root', 'root');
|
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once("../conf.php");
|
|
||||||
require_once("../class/these.php");
|
require_once("../class/these.php");
|
||||||
require_once("../class/dump.php");
|
require_once("../class/dump.php");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user