MySQLi isnt reuse persistent connections

bjc22

New Member
Centos 6.2, PHP 5.3.13 with mysqlndmysqli.allow_persistent OnThere is an example file to explain a question:\[code\]class foo{ private $link; public function __construct($host, $user, $pass, $db) { $this->link = mysqli_init(); try { $this->link->real_connect($host, $user, $pass, $db, 3306, NULL, MYSQLI_CLIENT_COMPRESS); } catch (mysqli_sql_exception $e) { echo $e->getCode() , $e->getMessage(); } $this->link->ping(); register_shutdown_function(array($this, "__shutdown_function")); } public function __shutdown_function() { $stats = $this->link->get_connection_stats(); echo $stats['pconnect_success'].'_'.$stats['connection_reused'].PHP_EOL; }}new foo('p:host','mysql','mysql','dbname');\[/code\]output of this example is always 1_0
 
Back
Top