From 28f6b969515ad0056e6385122aa3d7d76d6e7472 Mon Sep 17 00:00:00 2001 From: rudy Date: Tue, 3 May 2022 16:25:38 +0200 Subject: [PATCH] singleton pour la connection PDO --- src/Pdo/PdoConnect.php | 45 ++++++++++++++++++++++++++++++++++++ src/Services/PdoServices.php | 9 +++----- supervisord.log | 10 ++++++++ supervisord.pid | 2 +- 4 files changed, 59 insertions(+), 7 deletions(-) create mode 100644 src/Pdo/PdoConnect.php diff --git a/src/Pdo/PdoConnect.php b/src/Pdo/PdoConnect.php new file mode 100644 index 0000000..18f72bd --- /dev/null +++ b/src/Pdo/PdoConnect.php @@ -0,0 +1,45 @@ +params = $params; } - public function connection() - { - return new PDO($this->params->get('urlDatabase'), $this->params->get('dbUser'), $this->params->get('dbPassword')); - } - public function fetchDatas($email) { try { - $dbh = $this->connection(); + $pdo = PdoConnect::getInstance(); + $dbh = $pdo->connect($this->params->get('urlDatabase'), $this->params->get('dbUser'), $this->params->get('dbPassword')); $query = $dbh->prepare($this->getParameter('queryFetchDatas')); $query->execute(['email'=> $email]); $datas = $query->fetch(PDO::FETCH_ASSOC); diff --git a/supervisord.log b/supervisord.log index 809054b..c916816 100644 --- a/supervisord.log +++ b/supervisord.log @@ -4300,3 +4300,13 @@ 2022-05-03 14:32:13,009 INFO success: php-fpm entered RUNNING state, process has stayed up for > than 1 seconds (startsecs) 2022-05-03 14:32:13,011 INFO spawned: 'rsyslog' with pid 77 2022-05-03 14:32:14,019 INFO success: rsyslog entered RUNNING state, process has stayed up for > than 1 seconds (startsecs) +2022-05-03 16:04:28,347 CRIT Supervisor is running as root. Privileges were not dropped because no user is specified in the config file. If you intend to run as root, you can set user=root in the config file to avoid this message. +2022-05-03 16:04:28,349 INFO RPC interface 'supervisor' initialized +2022-05-03 16:04:28,349 CRIT Server 'unix_http_server' running without any HTTP authentication checking +2022-05-03 16:04:28,349 INFO supervisord started with pid 26 +2022-05-03 16:04:29,352 INFO spawned: 'apache2' with pid 27 +2022-05-03 16:04:29,353 INFO spawned: 'php-fpm' with pid 28 +2022-05-03 16:04:29,353 INFO spawned: 'rsyslog' with pid 29 +2022-05-03 16:04:30,374 INFO success: apache2 entered RUNNING state, process has stayed up for > than 1 seconds (startsecs) +2022-05-03 16:04:30,374 INFO success: php-fpm entered RUNNING state, process has stayed up for > than 1 seconds (startsecs) +2022-05-03 16:04:30,374 INFO success: rsyslog entered RUNNING state, process has stayed up for > than 1 seconds (startsecs) diff --git a/supervisord.pid b/supervisord.pid index 48082f7..6f4247a 100644 --- a/supervisord.pid +++ b/supervisord.pid @@ -1 +1 @@ -12 +26