Answer the question
In order to leave comments, you need to log in
PDO and connection support?
Hello!
There is a class for working with a DB database. In the designer I connect with a DB (MS Access). The fact is that an instance of the class is created in different parts of the code, and when displaying one page, it may happen that the constructor is called more than 10 times (as I understand it, 10 different connections are created?). This causes queries to take a very long time to complete.
If you connect to the database with the key , then the speed increases many times, but this is not advised to do (I was convinced by experience that after 5 minutes of work some tables were blocked due to incomplete execution of the script, as I understand it).
Actually, I would like to hear advice on how to get out of this situation. PDO::ATTR_PERSISTENT => true
Answer the question
In order to leave comments, you need to log in
Well, you can wrap PDO in a static class or some kind of singleton that will connect to the database only if the connection has not yet been established, or use an already established connection.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question