From 76ade95c18d88fdb8d8c49c32feba4839dabd489 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Tue, 13 Mar 2018 20:10:14 +0100 Subject: [PATCH] [repo.ue] now GET returns the field 'formations' that is a JSON array representation containing the 'formation' IDS --- build/database/repo/ue.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/build/database/repo/ue.php b/build/database/repo/ue.php index d9e6e0e..1f96004 100644 --- a/build/database/repo/ue.php +++ b/build/database/repo/ue.php @@ -179,10 +179,24 @@ class ue extends Repo_i { /* (2) Prepare Statement */ $this->pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); - $st = $this->pdo->prepare("SELECT ue.code, ue.label, ue.disabled, ue.required, ue.volumeCours, ue.volumeTD, ue.volumeTP, IFNULL(ue.Formation_idFormation, -1) idForm, f.labelFormation labelForm + $st = $this->pdo->prepare("SELECT + ue.code, + ue.label, + ue.disabled, + ue.required, + ue.volumeCours, + ue.volumeTD, + ue.volumeTP, + IFNULL(ue.Formation_idFormation, -1) idForm, + f.labelFormation labelForm, + IFNULL(CONCAT('[', GROUP_CONCAT(fc.idForm, ',', ftd.idForm, ',', ftp.idForm), ']'), '[]') formations FROM `UE` ue LEFT JOIN Formation f ON ue.Formation_idFormation = f.idFormation + LEFT JOIN ( SELECT DISTINCT gc.Formation_idFormation idForm, c.UE_code as code FROM GroupeCours gc, Cours c WHERE gc.Cours_idCours = c.idCours GROUP BY gc.Formation_idFormation ) fc ON fc.code = ue.code + LEFT JOIN ( SELECT DISTINCT gtd.Formation_idFormation idForm, td.UE_code as code FROM GroupeTD gtd, TD td WHERE gtd.TD_idTD = td.idTD GROUP BY gtd.Formation_idFormation ) ftd ON ftd.code = ue.code + LEFT JOIN ( SELECT DISTINCT gtp.Formation_idFormation idForm, tp.UE_code as code FROM GroupeTP gtp, TP tp WHERE gtp.TP_idTP = tp.idTP GROUP BY gtp.Formation_idFormation ) ftp ON ftp.code = ue.code $cond + GROUP BY ue.code ORDER BY `ue`.`label` ASC"); /* (3) Bind params and execute statement */