[repo.professor] added getByLogin (for CAS authentication check)

This commit is contained in:
xdrm-brackets 2018-03-03 14:30:52 +01:00
parent aadefed195
commit d7d08f07f8
1 changed files with 37 additions and 3 deletions

View File

@ -197,7 +197,41 @@ class professor extends Repo_i {
/* (6) Gets all professors
/* (6) Gets a professor by its CAS login
*
* @cas_login<String> The professor's CAS login
*
* @return teacher<array> The professor's data (NULL on error / not found)
*
---------------------------------------------------------*/
public function getByLogin(String $cas_login) : ?array{
/* (1) Prepare Statement */
$st = $this->pdo->prepare("SELECT * FROM `Professeur` WHERE `casLogin` = :cas_login");
/* (2) Bind params and execute statement */
$success = $st->execute([ ':cas_login' => $cas_login ]);
/* (3) Manage error */
if( !$success )
return NULL;
/* (4) Get data */
$fetched = $st->fetch();
/* (5) Return NULL on no result */
if( $fetched === false )
return NULL;
/* (6) Return data */
return $fetched;
}
/* (7) Gets all professors
*
* @return teachers<array> The professors' data ([] on error)
*
@ -219,7 +253,7 @@ class professor extends Repo_i {
/* (7) Deletes a professor
/* (8) Deletes a professor
*
* @return deleted<bool> Whether the professor have been deleeted successfully
*
@ -237,7 +271,7 @@ class professor extends Repo_i {
/* (8) Returns a professor's statistic data
/* (9) Returns a professor's statistic data
*
* @return data<array> Professor data
*