Introducing API feature (get these by author name).

This commit is contained in:
Florian SYLVAIN
2021-09-24 11:11:30 +02:00
parent 9774eb87f9
commit 241c411a87
2 changed files with 32 additions and 1 deletions
+19 -1
View File
@@ -1,5 +1,7 @@
<?php
require_once("these.php");
class dump {
private these $these;
@@ -14,6 +16,23 @@ class dump {
return date("Y-m-d", strtotime($old_date));
}
public static function getTheseByAuthor($author) : array {
$theses_array = [];
$pdo = new PDO('mysql:host=localhost;dbname=projet_prog_web;charset=utf8', 'root', 'root');
$stmt = $pdo->query("SELECT * FROM theses WHERE author = '$author';");
while ($obj = $stmt->fetchObject()) {
$i = 0;
$theses_array[`$i`] = array();
foreach ($obj as $elem) {
array_push($theses_array[`$i`], empty($elem) ? "NULL" : $elem);
$i++;
}
}
return $theses_array;
}
public function sendThese() {
$data = [
'author' => $this->these->getAuthor(),
@@ -39,5 +58,4 @@ class dump {
$stmt= $pdo->prepare($sql);
$stmt->execute($data);
}
}