From b28bb0b4daf239f56083b062b7e5f4f2ccf6452b Mon Sep 17 00:00:00 2001 From: Geoffrey Frogeye Date: Sun, 1 May 2016 12:01:31 +0200 Subject: [PATCH] api/transactions --- api/transactions.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+), 0 deletions(-) create mode 100644 api/transactions.php diff --git a/api/transactions.php b/api/transactions.php new file mode 100644 index 0000000..1180436 --- /dev/null +++ b/api/transactions.php @@ -0,0 +1,26 @@ +prepare("SELECT id, type, client, UNIX_TIMESTAMP(date), montant, quantite, utilisateur, valide FROM Transactions"); +if (!$requete) { + retour("erreur_bdd_preparee", ["message" => $db->error]); +} +if (!$requete->execute()) { + retour("erreur_bdd", ["message" => $requete->error]); +} +$requete->bind_result($id, $type, $client, $date, $montant, $quantite, $utilisateur, $valide); +$transactions = []; +while($requete->fetch()) { + $transaction = ["id" => $id, "type" => $type, "client" => $client, "date" => $date, "montant" => $montant, "quantite" => $quantite, "utilisateur" => $utilisateur, "valide" => $valide]; + $transactions[] = $transaction; + +} +$requete->close(); + + +retour("ok", ["transactions" => $transactions]); + +?> -- libgit2 0.21.2