> Le 30 sept. 2025 à 17:40, Larry Garfield <[email protected]> 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
