because your request is shit

This commit is contained in:
Unknown 2018-03-13 21:59:09 +01:00
parent 4999dcee05
commit 127132f9b2
1 changed files with 29 additions and 36 deletions

View File

@ -180,42 +180,35 @@ 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,
fdef.labelFormation labelForm,
IFNULL(formlist.formations, '[]') formations
FROM UE ue
LEFT JOIN Formation fdef ON ue.Formation_idFormation = fdef.idFormation
LEFT JOIN (
SELECT ue2.code code, CONCAT('[',GROUP_CONCAT(fform.idFormation), ']') formations
FROM UE ue2, Formation fform
WHERE ( fform.idFormation IN (
SELECT DISTINCT Formation_idFormation as idForm
FROM GroupeCours
WHERE Cours_idCours IN ( SELECT idCours FROM Cours WHERE UE_code = ue2.code GROUP BY idForm )
)
OR fform.idFormation IN (
SELECT DISTINCT Formation_idFormation as idForm
FROM GroupeTD
WHERE TD_idTD IN ( SELECT idTD FROM TD WHERE UE_code = ue2.code GROUP BY idForm )
)
OR fform.idFormation IN (
SELECT DISTINCT Formation_idFormation as idForm
FROM GroupeTP
WHERE TP_idTP IN ( SELECT idTP FROM TP WHERE UE_code = ue2.code GROUP BY idForm )
)
)
GROUP BY `ue2`.`code`
) formlist ON formlist.code = ue.code
$cond
GROUP BY `ue`.`code`
ORDER BY `ue`.`label` ASC");
ue.code,
ue.label,
ue.disabled,
ue.required,
ue.volumeCours,
ue.volumeTD,
ue.volumeTP,
IFNULL(ue.Formation_idFormation, -1) idForm,
fdef.labelFormation labelForm,
IFNULL(formlist.formations, '[]') formations
FROM UE ue
LEFT JOIN Formation fdef ON ue.Formation_idFormation = fdef.idFormation
LEFT JOIN (
SELECT ue2.code code, CONCAT('[',GROUP_CONCAT(DISTINCT Formation.idFormation), ']') formations
FROM UE ue2
LEFT JOIN Cours C ON ue2.code = C.UE_code
LEFT JOIN TD T ON ue2.code = T.UE_code
LEFT JOIN TP T2 ON ue2.code = T2.UE_code
LEFT JOIN GroupeCours C2 ON C.idCours = C2.Cours_idCours
LEFT JOIN GroupeTD TD2 ON T.idTD = TD2.TD_idTD
LEFT JOIN GroupeTP TP2 ON T2.idTP = TP2.TP_idTP
JOIN Formation ON C2.Formation_idFormation = Formation.idFormation
OR TD2.Formation_idFormation = Formation.idFormation
OR TP2.Formation_idFormation = Formation.idFormation
GROUP BY `ue2`.`code`
) formlist ON formlist.code = ue.code
##$cond
GROUP BY `ue`.`code`
ORDER BY `ue`.`label` ASC");
/* (3) Bind params and execute statement */
if( is_bool($st) ) return [];