Well, when i open pdo connection and close setting variable of connection as NULL it close the connection, but if i run some query then try to close and make the script sleep a bit, in show full processlist show as connection opened NULL, part of code:
conexao::OpenCon();
$output = self::$link->query('select count(id) from tb01')->fetchColumn();
conexao::CloseCon();
sleep(50);
echo $output;
These methods:
public static function CloseCon()
{
self::$link = NULL;
}
protected static function OpenCon()
{
try {
self::$link = new PDO('mysql:host='.DB_HOST.';dbname='.DB_NAME.';charset=utf8', DB_USER, DB_PASS);
self::$link->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
self::$link->exec('SET NAMES utf8');
} catch (PDOException $e) { die($e->getMessage()); }
}
Very strange cuz it only happens in my CentOs Linux Server, in Ubuntu it works fine, could it be some mysql configs?
Please someone help me, thanks.
Aucun commentaire:
Enregistrer un commentaire