[repo.category] added get() usual | [repo.professor] fix..
This commit is contained in:
parent
6bcccdae7f
commit
0a0135487f
|
@ -41,14 +41,14 @@ class category extends Repo_i{
|
|||
JOIN UE U ON Cours.UE_code = U.code
|
||||
WHERE U.disabled = 0
|
||||
GROUP BY Prof.Categorie_idCategorie) VHCours ON VHCours.idCat = Cat.idCategorie
|
||||
|
||||
|
||||
LEFT JOIN (SELECT IFNULL(SUM(TD.volume),0) VHTd , Prof.Categorie_idCategorie idCat
|
||||
FROM Professeur Prof
|
||||
LEFT JOIN TD ON TD.Professeur_idProfesseur = Prof.idProfesseur
|
||||
JOIN UE U2 ON TD.UE_code = U2.code
|
||||
WHERE U2.disabled = 0
|
||||
GROUP BY Prof.Categorie_idCategorie) VHTd ON VHTd.idCat = Cat.idCategorie
|
||||
|
||||
|
||||
LEFT JOIN (SELECT IFNULL(SUM(TP.volume),0) VHTp, Prof.Categorie_idCategorie idCat
|
||||
FROM Professeur Prof
|
||||
LEFT JOIN TP ON TP.Professeur_idProfesseur = Prof.idProfesseur
|
||||
|
@ -68,4 +68,41 @@ class category extends Repo_i{
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/* (4) Gets a category by its UID ||| getAll
|
||||
*
|
||||
* @cat_id<int> [OPT] The category UID, if not set, getAll()
|
||||
*
|
||||
* @return categories<array> The categories matching id (NULL on error)
|
||||
*
|
||||
---------------------------------------------------------*/
|
||||
public function get(?int $cat_id=null) : ?array{
|
||||
|
||||
/* (1) Manage if no id given */
|
||||
$cond = is_null($cat_id) ? '' : ' WHERE `idCategorie` = :id';
|
||||
$parm = is_null($cat_id) ? [] : [':id' => $cat_id];
|
||||
|
||||
/* (2) Prepare Statement */
|
||||
$st = $this->pdo->prepare("SELECT * FROM `Categorie`$cond ORDER BY `labelCategorie` ASC");
|
||||
|
||||
/* (3) Bind params and execute statement */
|
||||
if( is_bool($st) ) return [];
|
||||
$success = $st->execute($parm);
|
||||
|
||||
/* (4) Manage error */
|
||||
if( !$success )
|
||||
return [];
|
||||
|
||||
/* (5) Get data */
|
||||
$fetched = $st->fetchAll();
|
||||
|
||||
/* (6) Return [] on no result */
|
||||
if( $fetched === false )
|
||||
return [];
|
||||
|
||||
/* (7) Return data */
|
||||
return $fetched;
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -170,14 +170,14 @@ class professor extends Repo_i {
|
|||
* @return teachers<array> The professors matching id (NULL on error)
|
||||
*
|
||||
---------------------------------------------------------*/
|
||||
public function get(?int $prof_id=null) : ?array{
|
||||
public function get(?int $prof_id=null) : array{
|
||||
|
||||
/* (1) Manage if no id given */
|
||||
$cond = is_null($prof_id) ? '' : ' WHERE `idProfesseur` = :id';
|
||||
$parm = is_null($prof_id) ? [] : [':id' => $prof_id];
|
||||
|
||||
/* (2) Prepare Statement */
|
||||
$st = $this->pdo->prepare("SELECT * FROM `Professeur`$cond GROUP BY abreviation ASC");
|
||||
$st = $this->pdo->prepare("SELECT * FROM `Professeur`$cond ORDER BY abreviation ASC");
|
||||
|
||||
/* (3) Bind params and execute statement */
|
||||
if( is_bool($st) ) return [];
|
||||
|
@ -265,14 +265,14 @@ class professor extends Repo_i {
|
|||
LEFT JOIN UE U ON Cours.UE_code = U.code
|
||||
GROUP BY Prof.idProfesseur, U.disabled
|
||||
HAVING (U.disabled = 0 OR U.disabled IS NULL)) VHCours,
|
||||
|
||||
|
||||
(SELECT IFNULL(SUM(TD.volume),0) VHTd , Prof.idProfesseur idProf
|
||||
FROM Professeur Prof
|
||||
LEFT JOIN TD ON TD.Professeur_idProfesseur = Prof.idProfesseur
|
||||
LEFT JOIN UE U2 ON TD.UE_code = U2.code
|
||||
GROUP BY Prof.idProfesseur, U2.disabled
|
||||
HAVING (U2.disabled = 0 OR U2.disabled IS NULL)) VHTd,
|
||||
|
||||
|
||||
(SELECT IFNULL(SUM(TP.volume),0) VHTp, Prof.idProfesseur idProf
|
||||
FROM Professeur Prof
|
||||
LEFT JOIN TP ON TP.Professeur_idProfesseur = Prof.idProfesseur
|
||||
|
|
Loading…
Reference in New Issue