Commit b28bb0b4daf239f56083b062b7e5f4f2ccf6452b

Authored by Geoffrey PREUD'HOMME
1 parent cb0bbe24

api/transactions

Showing 1 changed file with 26 additions and 0 deletions   Show diff stats
api/transactions.php 0 → 100644
... ... @@ -0,0 +1,26 @@
  1 +<?php
  2 +
  3 +require_once("commun.php");
  4 +
  5 +verifierDroit(3);
  6 +
  7 +$requete = $db->prepare("SELECT id, type, client, UNIX_TIMESTAMP(date), montant, quantite, utilisateur, valide FROM Transactions");
  8 +if (!$requete) {
  9 + retour("erreur_bdd_preparee", ["message" => $db->error]);
  10 +}
  11 +if (!$requete->execute()) {
  12 + retour("erreur_bdd", ["message" => $requete->error]);
  13 +}
  14 +$requete->bind_result($id, $type, $client, $date, $montant, $quantite, $utilisateur, $valide);
  15 +$transactions = [];
  16 +while($requete->fetch()) {
  17 + $transaction = ["id" => $id, "type" => $type, "client" => $client, "date" => $date, "montant" => $montant, "quantite" => $quantite, "utilisateur" => $utilisateur, "valide" => $valide];
  18 + $transactions[] = $transaction;
  19 +
  20 +}
  21 +$requete->close();
  22 +
  23 +
  24 +retour("ok", ["transactions" => $transactions]);
  25 +
  26 +?>
... ...