chore (fetch datas) #39 : fermeture connexion sql après login$
This commit is contained in:
parent
5bfd8991ee
commit
085533b299
|
@ -26,6 +26,9 @@ class SQLLoginService extends AbstractController
|
||||||
|
|
||||||
public function fetchDatas(string $login): array
|
public function fetchDatas(string $login): array
|
||||||
{
|
{
|
||||||
|
if (empty($login)) {
|
||||||
|
throw new Exception('Connexion échouée, le login ne peut pas être vide');
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
$dbh = $this->getConnection();
|
$dbh = $this->getConnection();
|
||||||
} catch (PDOException $e) {
|
} catch (PDOException $e) {
|
||||||
|
@ -44,11 +47,15 @@ class SQLLoginService extends AbstractController
|
||||||
$query = $dbh->prepare($request);
|
$query = $dbh->prepare($request);
|
||||||
$query->execute([$this->sqlLoginRequest->getLoginColumnName() => $login]);
|
$query->execute([$this->sqlLoginRequest->getLoginColumnName() => $login]);
|
||||||
$datas = $query->fetch(PDO::FETCH_ASSOC);
|
$datas = $query->fetch(PDO::FETCH_ASSOC);
|
||||||
|
$query->closeCursor();
|
||||||
} catch (PDOException $e) {
|
} catch (PDOException $e) {
|
||||||
$this->loggerInterface->critical($e->getMessage());
|
$this->loggerInterface->critical($e->getMessage());
|
||||||
throw new DataToFetchConfigurationException($e->getMessage());
|
throw new DataToFetchConfigurationException($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (false === $datas) {
|
||||||
|
throw new Exception(sprintf('La requête sql "%s" a renvoyé un résultat incorrect.', $request));
|
||||||
|
}
|
||||||
return $datas;
|
return $datas;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue