Added back for disciplines and years charts

This commit is contained in:
Florian Sylvain
2022-01-08 18:54:04 +01:00
parent 80880dd377
commit ffffd33a82
4 changed files with 89 additions and 5 deletions
+85 -4
View File
@@ -49,7 +49,7 @@ class dump {
while ($obj = $stmt->fetchObject()) {
$theses_array[$i] = array();
foreach ($obj as $elem) {
array_push($theses_array[$i], empty($elem) ? "Non définit" : $elem);
$theses_array[$i][] = empty($elem) ? "Non définit" : $elem;
}
$i++;
}
@@ -81,7 +81,7 @@ class dump {
while ($obj = $stmt->fetchObject()) {
foreach ($obj as $elem) {
array_push($array, $elem);
$array[] = $elem;
}
}
@@ -116,13 +116,94 @@ class dump {
while ($obj = $stmt->fetchObject()) {
foreach ($obj as $elem) {
array_push($array, $elem);
$array[] = $elem;
}
}
return $array;
}
public static function getThesesYears(string $search, string $option) : array {
$years_array = [];
$pdo_obj = new conf();
$pdo = $pdo_obj->getPDO();
$search = '%' . $search . '%';
$stmt = match ($option) {
'auto' => $pdo->prepare("
SELECT DATE_FORMAT(date_soutenance, '%Y') AS Date,
COUNT(DATE_FORMAT(date_soutenance, '%Y')) AS Number
FROM `theses`
WHERE author LIKE :search
OR title LIKE :search
OR these_director LIKE :search
OR soutenance_establishment LIKE :search
GROUP BY Date
ORDER BY Date;
"),
'author' => $pdo->prepare("SELECT DATE_FORMAT(date_soutenance, '%Y') AS Date, COUNT(DATE_FORMAT(date_soutenance, '%Y')) AS Number FROM `theses` WHERE author LIKE :search GROUP BY Date ORDER BY Date;"),
'title' => $pdo->prepare("SELECT DATE_FORMAT(date_soutenance, '%Y') AS Date, COUNT(DATE_FORMAT(date_soutenance, '%Y')) AS Number FROM `theses` WHERE title LIKE :search GROUP BY Date ORDER BY Date;"),
'director' => $pdo->prepare("SELECT DATE_FORMAT(date_soutenance, '%Y') AS Date, COUNT(DATE_FORMAT(date_soutenance, '%Y')) AS Number FROM `theses` WHERE these_director LIKE :search GROUP BY Date ORDER BY Date;"),
'establishment' => $pdo->prepare("SELECT DATE_FORMAT(date_soutenance, '%Y') AS Date, COUNT(DATE_FORMAT(date_soutenance, '%Y')) AS Number FROM `theses` WHERE soutenance_establishment LIKE :search GROUP BY Date ORDER BY Date;"),
default => "",
};
$stmt->bindParam(':search', $search, PDO::PARAM_STR, 100);
$stmt->execute();
$i = 0;
while ($obj = $stmt->fetchObject()) {
$years_array[$i] = array();
$years_array[$i][$obj->Date] = $obj->Number;
$i++;
}
return $years_array;
}
public static function getThesesDisciplines(string $search, string $option) : array {
$disciplines_array = [];
$pdo_obj = new conf();
$pdo = $pdo_obj->getPDO();
$search = '%' . $search . '%';
$stmt = match ($option) {
'auto' => $pdo->prepare("
SELECT discipline AS Discipline,
COUNT(discipline) AS Number
FROM `theses`
WHERE author LIKE :search
OR title LIKE :search
OR these_director LIKE :search
OR soutenance_establishment LIKE :search
GROUP BY Discipline
ORDER BY `Number` DESC
LIMIT 10
"),
'author' => $pdo->prepare("SELECT discipline AS Discipline, COUNT(discipline) AS Number FROM `theses` WHERE author LIKE :search GROUP BY Discipline ORDER BY `Number` DESC LIMIT 10;"),
'title' => $pdo->prepare("SELECT discipline AS Discipline, COUNT(discipline) AS Number FROM `theses` WHERE title LIKE :search GROUP BY Discipline ORDER BY `Number` DESC LIMIT 10;"),
'director' => $pdo->prepare("SELECT discipline AS Discipline, COUNT(discipline) AS Number FROM `theses` WHERE these_director LIKE :search GROUP BY Discipline ORDER BY `Number` DESC LIMIT 10;"),
'establishment' => $pdo->prepare("SELECT discipline AS Discipline, COUNT(discipline) AS Number FROM `theses` WHERE soutenance_establishment LIKE :search GROUP BY Discipline ORDER BY `Number` DESC LIMIT 10;"),
default => "",
};
$stmt->bindParam(':search', $search, PDO::PARAM_STR, 100);
$stmt->execute();
$i = 0;
while ($obj = $stmt->fetchObject()) {
$disciplines_array[$i] = array();
$disciplines_array[$i][$obj->Discipline] = $obj->Number;
$i++;
}
return $disciplines_array;
}
public function sendThese($pdo) {
$data = [
'author' => $this->these->getAuthor(),
@@ -147,4 +228,4 @@ class dump {
$stmt = $pdo->prepare($sql);
$stmt->execute($data);
}
}
}