add casLogin option for professor.exists

This commit is contained in:
Unknown 2018-03-11 16:26:04 +01:00
parent 24f7c41705
commit 13c01ef144
1 changed files with 11 additions and 4 deletions

View File

@ -64,19 +64,26 @@ class professor extends Repo_i {
* @return prof_id<int> The professor's UID (or NULL on error)
*
---------------------------------------------------------*/
public function exists(string $lastName, string $firstName) : ?int{
public function exists(string $lastName, string $firstName, ?string $casLogin = null) : ?int{
/* (1) Prepare Statement */
$st = $this->pdo->prepare("SELECT idProfesseur
FROM Professeur
WHERE firstName = :firstName
AND lastName = :lastName");
AND lastName = :lastName
".(is_string($casLogin) ? "AND casLogin = :casLogin" : ""));
/* (2) Bind params and execute */
$success = $st->execute([
$params = [
':firstName' => $firstName,
':lastName' => $lastName
]);
];
if(is_string($casLogin)){
$params[":casLogin"] = $casLogin;
}
$success = $st->execute();
/* (3) Return NULL on error */
if( !$success )