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