|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2013-04-07 07:11 UTC] slavb18 at gmail dot com
Description:
------------
PHP PDO class is missing ability to close persistent connection:
__destruct does not close it, even if I call setAttribute(PDO::ATTR_PERSISTENT,FALSE) before destruction
May be __destruct should analyze PDO::ATTR_PERSISTENT attribute or there should be explicit function to close persistent connection.
Need to close invalid (shutdown) peristent connection demonstrate example below:
Example with firebird:
1. establish persistent connect in php
2. shutdown connection on server
3. try to get persistent connect from php again
there will be error "General error: -902 connection shutdown"
I can check connection validity in my pdo derived class like this:
public function isValid(){
$valid=TRUE;
try {
$this->beginTransaction();
$this->commit();
} catch (PDOException $e){
$valid=FALSE;
}
return $valid;
}
but I can not "refresh" or "close" my broken connection, there is no function to free it in php connection pool
Patchesphp5-bug64603.patch (last revision 2013-09-18 05:26 UTC by slavb18 at gmail dot com)Pull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 23 22:00:01 2025 UTC |
may be there is also third way to resolve problem 1. PDO class should have function public function isValid(){ return TRUE; // or some embedded functional like start/finish transaction ? dont know how it work with other drivers } 2. derived class override & implement method isValid() (like in my example) 3. php before returning PDO class from connection pool should call isValid() method, and if validation the result is false, then automatically refresh connection