Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:128748 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by lists.php.net (Postfix) with ESMTPS id 24B4A1A00BC for ; Tue, 30 Sep 2025 20:08:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1759262827; bh=XyU2zr6A3+xOHTiSsGF8Wq1lGTNnb7/y93tLIuB+hx0=; h=From:Subject:Date:In-Reply-To:Cc:To:References:From; b=lgOsJYUuSMrb0KcvhnOZdrkwr8w2aQUci7pHSZF6HqYhdG4l5rhlXkxk3MV55jv3T dEwI+WEREbtu/Fa7YF/QGw1JLmXubQEHYxkO9b377g6GLwmWxqABOUXhrS5285N5RM MjqECtUJ51xU395pKFW1NU9SmEMLE0QOC4aX2TKGd4btukVIplgfSk/c+H6AZnCkTi 6BWnvY2a1uzGfunNAx/S2Z3zGxmFx2+QXscZtLkk8vfI5URqmvPJ41VIQMxSxSw1tY oWOQUuE4q3pP9wdDWxUkCn/FMCwXY2sYB+Y5FcwlsmZkAqFNOqto/DVW6n9HNX+XG1 RbGAScV4gl41g== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 143FC1801DB for ; Tue, 30 Sep 2025 20:07:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.2 required=5.0 tests=BAYES_40,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 30 Sep 2025 20:07:03 +0000 (UTC) Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-3ee1221ceaaso5142329f8f.3 for ; Tue, 30 Sep 2025 13:08:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1759262902; x=1759867702; darn=lists.php.net; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:from:to:cc:subject:date:message-id:reply-to; bh=207K/d3jWcQc1F4QiACkBIkPyANs4Io/mfxAGjK4MmE=; b=fyaNe8clg+8rgaYBA0AzZHM1eM16wkpbmHDpCcw8H5gxQlnS8OckXbzzYAQoYL6x8f GIEXMZS6TdasafEoiA+JZAOvGQyjyYh64DMtIARRPkRF2Sx065ZaNuNE6AcaMxBnIumw IpKTh5tH/1wxW/yp2inMRTYHifQVC+bFuK7Z/GcdKoCSlcjtL1x+1Yhoc210ZCeeRb21 blsBB3vIorZ7In3fwDsLsDliXUeBmNYwZO1CoNfkFxWUuUVnH2DOfGYsr3R+xCg+E6sb m2JLeXp9wxs10VE/jVIq7ozDew+3tcl65OnpXZ/w+ELyb6FqJbC2ua7OEFfdy3j3vUBG PyZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759262902; x=1759867702; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=207K/d3jWcQc1F4QiACkBIkPyANs4Io/mfxAGjK4MmE=; b=OHVx5v7gsD2jrsZAhlMDw8V+IpVDok0Oh+wN6MZWf8F8znYu0QqOTdiBxIe5pskrsz kGYIUCye9KQGIK81WfdjMJtIePRRk+1cDnM3p7P7eD13clc8NCHTWjBnc5G1ZN5jkex9 wYQhhK/QJIiCjZCICvCeYP+7xecRXfUXInkEQzAJPKUNTyZMjvduJK1yU87aaqsdGhCB gkXJcwqcq809OxYEp1X3Fpc5T4NP/VRHKS7QI3aTbLBtERlEQBcNgYD0vzKtoOTXvOzP BnRk+8w49/oErkOJOXZY9WR5fo6OBJ1dhYU49BNVMta+lpD/QFEL1lvaLEUZRPR1nUdH sf6g== X-Gm-Message-State: AOJu0Yw4zbdH1PBjjQ0fVvvsP3aWYGjMJm4G2UdAfAwNh050J0R+N1Oh JhPlWmzYFwPbI6qQwU6gbh3MHZQnn1Vv0idVH7l5OozakORlV2D8AyBPKXIc/w== X-Gm-Gg: ASbGncsjd8QSTten+sKiMlorCk/WGe4zH5QlYEwxzkKrgXD1a46p47pQ/HJjh5W4TrS 8UDJ5B1VQOgR/T1TV5HB6jWubTeLFhzK31WLtbWL+VTLVDaqoDT5VSfe+nIZ6CdQpWQmSXc61cS iy3dXabn61y2xzZroZwp0ALy7Vf99JlRk2fTqpA3Y4KmJAM1m6ghJaFDjleTOW8CFXxIyrTfw5c lQRA6hFqXR0cz7L2cLRFZ1YiSkrzAmZjlOeKd0SrOCY/h1voH+ZJZvyLmLSfXY6PnScRQBdOiUk nh7xVccP+sgC8UYZdsKlL3lIinaRdLdty7wnfRpIgGM4nJVmVmSt00YagY+t33F6AiH1tUc9AeU krX+aRfnmk/KcBpH4jPPA+ZsRS/suOFXFeOY9cl0BxITP/lZa9ezol15lz2lXcrcf X-Google-Smtp-Source: AGHT+IFs14+cwswtIcVbOyhq8Gy+0Zvdjl4D1mGdn/x2ZRq2xlyymadtJNXPQl+71F/JIxHFg1BLfw== X-Received: by 2002:a05:6000:310d:b0:3da:27c2:f51d with SMTP id ffacd0b85a97d-4255781b83cmr812154f8f.45.1759262901543; Tue, 30 Sep 2025 13:08:21 -0700 (PDT) Received: from smtpclient.apple ([89.249.45.14]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-40fb89fb2fcsm25772346f8f.22.2025.09.30.13.08.20 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Sep 2025 13:08:21 -0700 (PDT) Message-ID: Content-Type: multipart/alternative; boundary="Apple-Mail=_E7F7CE48-FD27-4EC6-BFFC-4BC91A6C5D5C" Precedence: list list-help: list-post: List-Id: x-ms-reactions: disallow Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3826.700.81\)) Subject: Re: [PHP-DEV] [Discuss] Add PDO disconnect() and isConnected() Date: Tue, 30 Sep 2025 22:08:08 +0200 In-Reply-To: <4ddd9a25-47b8-4a2b-ad93-e93f8f33922b@app.fastmail.com> Cc: php internals To: Larry Garfield References: <4ddd9a25-47b8-4a2b-ad93-e93f8f33922b@app.fastmail.com> X-Mailer: Apple Mail (2.3826.700.81) From: claude.pache@gmail.com (Claude Pache) --Apple-Mail=_E7F7CE48-FD27-4EC6-BFFC-4BC91A6C5D5C Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > Le 30 sept. 2025 =C3=A0 17:40, Larry Garfield = a =C3=A9crit : >=20 >=20 > 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. >=20 > What that would look like, I'm not sure. Just spitballing: >=20 > // After X seconds, drop and reopen the connection the next time it's = used. > $pdo->reconnectAfter($seconds); >=20 > --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... =E2=80=94Claude= --Apple-Mail=_E7F7CE48-FD27-4EC6-BFFC-4BC91A6C5D5C Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8
Le 30 sept. = 2025 =C3=A0 17:40, Larry Garfield <larry@garfieldtech.com> a = =C3=A9crit :


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...

=E2=80=94Claude
= --Apple-Mail=_E7F7CE48-FD27-4EC6-BFFC-4BC91A6C5D5C--