add casLogin option for professor.exists
This commit is contained in:
parent
24f7c41705
commit
13c01ef144
|
@ -64,19 +64,26 @@ class professor extends Repo_i {
|
||||||
* @return prof_id<int> The professor's UID (or NULL on error)
|
* @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 */
|
/* (1) Prepare Statement */
|
||||||
$st = $this->pdo->prepare("SELECT idProfesseur
|
$st = $this->pdo->prepare("SELECT idProfesseur
|
||||||
FROM Professeur
|
FROM Professeur
|
||||||
WHERE firstName = :firstName
|
WHERE firstName = :firstName
|
||||||
AND lastName = :lastName");
|
AND lastName = :lastName
|
||||||
|
".(is_string($casLogin) ? "AND casLogin = :casLogin" : ""));
|
||||||
|
|
||||||
/* (2) Bind params and execute */
|
/* (2) Bind params and execute */
|
||||||
$success = $st->execute([
|
$params = [
|
||||||
':firstName' => $firstName,
|
':firstName' => $firstName,
|
||||||
':lastName' => $lastName
|
':lastName' => $lastName
|
||||||
]);
|
];
|
||||||
|
|
||||||
|
if(is_string($casLogin)){
|
||||||
|
$params[":casLogin"] = $casLogin;
|
||||||
|
}
|
||||||
|
|
||||||
|
$success = $st->execute();
|
||||||
|
|
||||||
/* (3) Return NULL on error */
|
/* (3) Return NULL on error */
|
||||||
if( !$success )
|
if( !$success )
|
||||||
|
|
Loading…
Reference in New Issue