catfan / Medoo

The lightweight PHP database framework to accelerate the development.
https://medoo.in
MIT License
4.84k stars 1.15k forks source link

How to manually open and close a connection? #904

Closed jenokizm closed 3 years ago

jenokizm commented 4 years ago

For example, I want to write a delay function before some bot answers to a user, but at the same time so as not to block an unnecessary connection.

use Medoo\Medoo;

$database = new Medoo([
    'database_type' => 'mysql',
    'database_name' => 'testdb',
    'server' => 'localhost',
    'username' => 'root',
    'password' => ''
]);

function sleepMy()
{
    $database->close();
    sleep(3);
    $database->reopen();
}

how to do it?

mrqaidi commented 3 years ago

i need this too i need to close mysql when i have long php execute

LikeNeko commented 3 years ago

我也需要这个,当我长时间执行php时,我需要关闭mysql

$database->pdo=null;

catfan commented 3 years ago

Destructing the $database->pdo or the Medoo object is the right way to close the connection.