Fully functioning these and dump features implemented.

This commit is contained in:
Florian SYLVAIN
2021-09-24 09:54:28 +02:00
parent 788182e8d8
commit e95474300b
2 changed files with 62 additions and 46 deletions
+13 -9
View File
@@ -10,25 +10,29 @@ class dump {
$this->these = $these; $this->these = $these;
} }
public static function convertDate($old_date) : string {
return date("Y-m-d", strtotime($old_date));
}
public function sendThese() { public function sendThese() {
$data = [ $data = [
'author' => $this->these->getAuthor(), 'author' => $this->these->getAuthor(),
'id_author' => $this->these->getIdAuthor(), 'id_author' => empty($this->these->getIdAuthor()) ? NULL : $this->these->getIdAuthor(),
'these_director' => $this->these->getTheseDirector(), 'these_director' => $this->these->getTheseDirector(),
'title' => $this->these->getTitle(), 'title' => $this->these->getTitle(),
'these_director_name_lastname' => $this->these->getTheseDirectorNameLastname(), 'these_director_name_lastname' => $this->these->getTheseDirectorNameLastname(),
'id_director' => $this->these->getIdDirector(), 'id_director' => empty($this->these->getIdDirector()) ? NULL : $this->these->getIdDirector(),
'soutenance_establishment' => $this->these->getSoutenanceEstablishment(), 'soutenance_establishment' => $this->these->getSoutenanceEstablishment(),
'id_establishment' => $this->these->getIdEstablishment(), 'id_establishment' => empty($this->these->getIdEstablishment()) ? NULL : $this->these->getIdEstablishment(),
'discipline' => $this->these->getDiscipline(), 'discipline' => $this->these->getDiscipline(),
'status' => $this->these->getStatus(), 'status' => $this->these->getStatus(),
'date_first_registration' => $this->these->getDateFirstRegistration(), 'date_first_registration' => empty($this->these->getDateFirstRegistration()) ? NULL : $this->these->getDateFirstRegistration(),
'date_soutenance' => $this->these->getDateSoutenance(), 'date_soutenance' => empty($this->these->getDateSoutenance()) ? NULL : $this->these->getDateSoutenance(),
'language' => $this->these->getLanguage(), 'language' => empty($this->these->getLanguage()) ? NULL : $this->these->getLanguage(),
'id_these' => $this->these->getIdThese(), 'id_these' => empty($this->these->getIdThese()) ? NULL : $this->these->getIdThese(),
'online' => $this->these->isOnline() ? "yes" : "no", 'online' => $this->these->isOnline() ? "yes" : "no",
'date_publication' => $this->these->getDatePublication(), 'date_publication' => empty($this->these->getDatePublication()) ? NULL : $this->these->getDatePublication(),
'date_update' => $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 = new PDO('mysql:host=localhost;dbname=projet_prog_web', 'root', 'root');
+49 -37
View File
@@ -1,5 +1,7 @@
<?php <?php
use JetBrains\PhpStorm\Pure;
class these { class these {
private string $author; private string $author;
private string $id_author; private string $id_author;
@@ -19,43 +21,53 @@ class these {
private string $date_publication; private string $date_publication;
private string $date_update; private string $date_update;
/** #[Pure] public static function emptyThese(): these
* @param string $author {
* @param string $id_author return new self();
* @param string $title }
* @param string $these_director
* @param string $these_director_name_lastname public static function fullThese(string $author, string $id_author, string $title, string $these_director, string $these_director_name_lastname, string $id_director, string $soutenance_establishment, string $id_establishment, string $discipline, string $status, string $date_first_registration, string $date_soutenance, string $language, string $id_these, bool $online, string $date_publication, string $date_update) {
* @param string $id_director $these = these::emptyThese();
* @param string $soutenance_establishment $these->setAuthor($author);
* @param string $id_establishment $these->setIdAuthor($id_author);
* @param string $discipline $these->setTitle($title);
* @param string $status $these->setTheseDirector($these_director);
* @param string $date_first_registration $these->setTheseDirectorNameLastname($these_director_name_lastname);
* @param string $date_soutenance $these->setIdDirector($id_director);
* @param string $language $these->setSoutenanceEstablishment($soutenance_establishment);
* @param string $id_these $these->setIdEstablishment($id_establishment);
* @param bool $online $these->setDiscipline($discipline);
* @param string $date_publication $these->setStatus($status);
* @param string $date_update $these->setDateFirstRegistration($date_first_registration);
*/ $these->setDateSoutenance($date_soutenance);
public function __construct(string $author, string $id_author, string $title, string $these_director, string $these_director_name_lastname, string $id_director, string $soutenance_establishment, string $id_establishment, string $discipline, string $status, string $date_first_registration, string $date_soutenance, string $language, string $id_these, bool $online, string $date_publication, string $date_update) { $these->setLanguage($language);
$this->author = $author; $these->setIdThese($id_these);
$this->id_author = $id_author; $these->setOnline($online);
$this->title = $title; $these->setDatePublication($date_publication);
$this->these_director = $these_director; $these->setDateUpdate($date_update);
$this->these_director_name_lastname = $these_director_name_lastname; return $these;
$this->id_director = $id_director; }
$this->soutenance_establishment = $soutenance_establishment;
$this->id_establishment = $id_establishment; public function insertField($field, $index) {
$this->discipline = $discipline; switch ($index) {
$this->status = $status; case 0: $this->setAuthor($field); break;
$this->date_first_registration = $date_first_registration; case 1: $this->setIdAuthor($field); break;
$this->date_soutenance = $date_soutenance; case 2: $this->setTitle($field); break;
$this->language = $language; case 3: $this->setTheseDirector($field); break;
$this->id_these = $id_these; case 4: $this->setTheseDirectorNameLastname($field); break;
$this->online = $online; case 5: $this->setIdDirector($field); break;
$this->date_publication = $date_publication; case 6: $this->setSoutenanceEstablishment($field); break;
$this->date_update = $date_update; case 7: $this->setIdEstablishment($field); break;
case 8: $this->setDiscipline($field); break;
case 9: $this->setStatus($field); break;
case 10: $this->setDateFirstRegistration(dump::convertDate($field)); break;
case 11: $this->setDateSoutenance(dump::convertDate($field)); break;
case 12: $this->setLanguage($field); break;
case 13: $this->setIdThese($field); break;
case 14: $this->setOnline($field); break;
case 15: $this->setDatePublication(dump::convertDate($field)); break;
case 16: $this->setDateUpdate(dump::convertDate($field)); break;
}
} }
/** /**