singleton pour la connection PDO
This commit is contained in:
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Pdo\PdoConnect;
|
||||
use PDO;
|
||||
use PDOException;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
@ -16,15 +17,11 @@ class PdoServices extends AbstractController
|
||||
$this->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);
|
||||
|
Reference in New Issue
Block a user