aboutsummaryrefslogtreecommitdiff
path: root/src/controller/UserController.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/controller/UserController.php')
-rw-r--r--src/controller/UserController.php10
1 files changed, 5 insertions, 5 deletions
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
22 // account 22 // account
23 static public function existUsers(EntityManager $entityManager): bool 23 static public function existUsers(EntityManager $entityManager): bool
24 { 24 {
25 // optimiser ça si possible, on veut juste savoir si la table est vide ou non 25 $nb_users = $entityManager
26 $users = $entityManager->getRepository(User::class)->findAll(); 26 ->createQuery('SELECT COUNT(u.id_user) FROM App\Entity\User u')
27 27 ->getSingleScalarResult();
28 if(count($users) === 0) // table vide 28
29 if($nb_users === 0) // table vide
29 { 30 {
30 $_SESSION['user'] = ''; 31 $_SESSION['user'] = '';
31 $_SESSION['admin'] = false; 32 $_SESSION['admin'] = false;
32
33 return false; 33 return false;
34 } 34 }
35 else{ 35 else{