Re: [Discuss] Add PDO disconnect() and isConnected()
| From: | Claude Pache | Date: | Tue, 30 Sep 2025 20:08:08 +0000 |
| Subject: | Re: [Discuss] Add PDO disconnect() and isConnected() | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-128748@lists.php.net to get a copy of this message | ||
> Le 30 sept. 2025 à 17:40, Larry Garfield <larry@garfieldtech.com> a écrit :
>
>
> What would be valuable is easier RE-connection logic. Either PHP or MySQL may terminate an
> idle connection, which is a concern in long-running processes (Queue workers, ReactPHP, Franken,
> etc.). Tools like Doctrine have built their own refresh logic in, although they're not always
> consistent with each other or obvious to use. Having some kind of reconnection logic built into PDO
> that "just works" would be very valuable.
>
> What that would look like, I'm not sure. Just spitballing:
>
> // After X seconds, drop and reopen the connection the next time it's used.
> $pdo->reconnectAfter($seconds);
>
> --Larry Garfield
Auto-reconnection is dangerous, because database engines are stateful. For example, disaster will
happen if disconnection had occurred in the middle of a transaction...
—Claude