Blame view

api/transactions.php 800 Bytes
b28bb0b4   Geoffrey PREUD'HOMME   api/transactions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
  <?php
  
  require_once("commun.php");
  
  verifierDroit(3);
  
  $requete = $db->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]);
  
  ?>