mirror of
https://gitlab.aliens-lyon.fr/savrillo/gpens.git
synced 2026-09-11 22:30:46 +02:00
Une première version de l'application.
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
// Connection à la BDD:
|
||||
try {
|
||||
$conn = new PDO("mysql:host=localhost;dbname=savrillo", savrillo, "BHTvo0JfS");
|
||||
// set the PDO error mode to exception
|
||||
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
} catch(PDOException $e) {
|
||||
echo "Connection failed: " . $e->getMessage();
|
||||
}
|
||||
|
||||
|
||||
if($_GET["salle"] != NULL) {
|
||||
|
||||
$idSalle = $_GET["salle"];
|
||||
|
||||
$aliaz = array();
|
||||
|
||||
$stmt = $conn->prepare("SELECT nom FROM salleAlias WHERE salleID=?");
|
||||
$stmt->execute([$idSalle]);
|
||||
$resA = $stmt->fetchAll();
|
||||
|
||||
for($i=0;$i<count($resA);$i++)
|
||||
$aliaz[$i] = $resA[$i]['nom'];
|
||||
|
||||
$locataires = array();
|
||||
|
||||
$stmt = $conn->prepare("SELECT personne FROM locataire WHERE salle=?");
|
||||
$stmt->execute([$idSalle]);
|
||||
$resP = $stmt->fetchAll();
|
||||
|
||||
for($i=0;$i<count($resP);$i++)
|
||||
$locataires[$i] = $resP[$i]['nom'];
|
||||
|
||||
|
||||
$stmt = $conn->prepare("SELECT id, nom, description FROM salles WHERE id=?");
|
||||
$stmt->execute([$idSalle]);
|
||||
$resS = $stmt->fetchAll();
|
||||
|
||||
|
||||
if(count($resS)==0){
|
||||
echo "404";
|
||||
}else {
|
||||
$out = array("id" => $resS[0]["id"], "nom" => $resS[0]["nom"], "description" => $resS[0]["description"], "aliaz" => $aliaz, "locataires" => $locataires);
|
||||
echo (json_encode($out));
|
||||
}
|
||||
|
||||
}else {
|
||||
echo "Je ne connais pas cette commande ...";
|
||||
}
|
||||
Reference in New Issue
Block a user