From e642cd51d7e8599537f8514bef8d5d16096dddf8 Mon Sep 17 00:00:00 2001 From: polo Date: Wed, 27 Aug 2025 16:08:29 +0200 Subject: =?UTF-8?q?optimisation=20UserController::existUsers,=20gestion=20?= =?UTF-8?q?des=20$response=20par=20le=20routeur,=20erreur=20article=20d?= =?UTF-8?q?=C3=A9j=C3=A0=20supprim=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controller/UserController.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/controller/UserController.php') diff --git a/src/controller/UserController.php b/src/controller/UserController.php index 1acb4d5..a35b09e 100644 --- a/src/controller/UserController.php +++ b/src/controller/UserController.php @@ -22,14 +22,14 @@ class UserController // account static public function existUsers(EntityManager $entityManager): bool { - // optimiser ça si possible, on veut juste savoir si la table est vide ou non - $users = $entityManager->getRepository(User::class)->findAll(); - - if(count($users) === 0) // table vide + $nb_users = $entityManager + ->createQuery('SELECT COUNT(u.id_user) FROM App\Entity\User u') + ->getSingleScalarResult(); + + if($nb_users === 0) // table vide { $_SESSION['user'] = ''; $_SESSION['admin'] = false; - return false; } else{ -- cgit v1.2.3