Re: [Discuss] Add PDO disconnect() and isConnected()

From: Date: Thu, 09 Oct 2025 17:47:35 +0000
Subject: Re: [Discuss] Add PDO disconnect() and isConnected()
References: 1 2 3 4 5 6  Groups: php.internals 
Request: Send a blank email to internals+get-128798@lists.php.net to get a copy of this message
> I would argue we should discourage their use
> (deprecation is my dream!)

I am with you on the deprecation of persistent connections, as the
implementation is awkward, but not without addressing the use case.

> As you well know, PDO is an object which also optionally uses PHP
persistent resources to facilitate connection re-use across PHP requests, a
feature which I don't believe has a parallel in object space. Perhaps > >
therein lies a feature request, i.e. to allow an object to be made
persistent in the same way a resource can.

I floated the above idea. Any inclination that would be worth pursuing?

> ... would be an interface to declare the persistent connection as
defunct, such that upon subsequent PDO creation, a new connection will be
formed, and the former will be closed. This is distinct from a disconnect
or > reconnect procedure, and similar to failing a "liveness" check upon
persistent PDO creation. Users could then effectively replace their
persistent PDO in the same manner they would do so for a "regular" PDO.

This idea is growing on me, to address the issue of a defunct persistent
connection, rather than the disconnect() interface. Any thoughts on
introducing a new attribute to the PDO constructor to prompt the
reconnection: PDO::ATTR_PERSISTENT_RECONNECT.

-Robert


Thread (22 messages)

« previous php.internals (#128798) next »