[repo.ue] now GET returns the field 'formations' that is a JSON array representation containing the 'formation' IDS

This commit is contained in:
xdrm-brackets 2018-03-13 20:10:14 +01:00
parent 3a8178a352
commit 76ade95c18
1 changed files with 15 additions and 1 deletions

View File

@ -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 */