From 241c411a8738d228e42648a21932f00db0a8b70f Mon Sep 17 00:00:00 2001 From: Florian SYLVAIN Date: Fri, 24 Sep 2021 11:11:30 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Introducing=20API=20feature=20(get?= =?UTF-8?q?=20these=20by=20author=20name).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ProjetProgWeb/api.php | 13 +++++++++++++ ProjetProgWeb/class/dump.php | 20 +++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 ProjetProgWeb/api.php diff --git a/ProjetProgWeb/api.php b/ProjetProgWeb/api.php new file mode 100644 index 0000000..3c140d3 --- /dev/null +++ b/ProjetProgWeb/api.php @@ -0,0 +1,13 @@ +'; +var_dump($json); +echo ''; diff --git a/ProjetProgWeb/class/dump.php b/ProjetProgWeb/class/dump.php index 468d1f3..2059e25 100644 --- a/ProjetProgWeb/class/dump.php +++ b/ProjetProgWeb/class/dump.php @@ -1,5 +1,7 @@ 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); } - } \ No newline at end of file