H
H
HellWalk2021-05-12 17:46:24
symfony
HellWalk, 2021-05-12 17:46:24

How in Doctrine, in DBAL to specify PDO::ATTR_PERSISTENT => true?

In tests I get an error:

[Doctrine\DBAL\Exception\ConnectionException] An exception occurred in driver: SQLSTATE[08006] [7] IMPORTANT: sorry, too many clients already


Accordingly, you need to specify the doctrine so that it uses one connection for all requests. Directly through php, this is done like this:

$connection = new PDO('DSN', 'user', 'password', [PDO::ATTR_PERSISTENT => true]);

But how to specify a similar parameter in the doctrine?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Fedorov, 2021-05-12
@Maksclub

The entity manager uses one Connection object, the Connection uses the PDO object, there is always one connection everywhere and it works throughout the entire life cycle of the application, this is the essence of the work (well, including) of the DI container - to give the same object and not produce them. That is, everything works for the life cycle of the application.
Tests are functional? Can many http requests in different processes breed? But if so, then all the same, the processes are different and the PDO objects are different, so your setting will not work, because the applications themselves will just be different ...
For such cases, Codeception has such a thing as persistService, in theory a service (in your case, EntityManager , if you work through it, or Connection, if you work through DBAL) one must go through this single thing, even if different http requests
https://codeception.com/docs/modules/Symfony#persi...
Krch, reveal some details of your tests and the situation, maybe I'm writing everything in the wrong place

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question