Answer the question
In order to leave comments, you need to log in
How to connect to mysql as needed?
There is a project with old mysql. Almost all parts have been replaced by pdo, but in some places on the site there is still old code, which will be replaced over time. Now you have to use the database using the DB class and the old permanent connection.
How can I make this permanently old connection open when needed?
Looking for something like
if(session_id() == '') {
session_start();
}
Answer the question
In order to leave comments, you need to log in
What's the problem with doing
if (!$db)
$db = new \PDO(...
$db = new PDO('mysql:host=localhost;dbname=test', $user, $pass, array(
PDO::ATTR_PERSISTENT => true
));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question