From 09d06bc0857c2f5faec7b1bf70e62d30a9c1bb3d Mon Sep 17 00:00:00 2001 From: Guillermo Pages Date: Thu, 12 Feb 2026 23:28:22 +0100 Subject: [PATCH] fix: add persistent connections + fix self::$pdo bug MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add PDO::ATTR_PERSISTENT to prevent SQL Server connection storms under concurrent PHP-FPM load (was causing 241 SQLSTATE[08001] failures/day on callioapi) - Fix bug: $pdo → self::$pdo in connect() and getPDOInstance() guards (was checking undefined local var instead of static prop) --- src/PDOWithFilters/PDOWithFilters.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/PDOWithFilters/PDOWithFilters.php b/src/PDOWithFilters/PDOWithFilters.php index dd387ce..beee684 100644 --- a/src/PDOWithFilters/PDOWithFilters.php +++ b/src/PDOWithFilters/PDOWithFilters.php @@ -35,16 +35,16 @@ class PDOWithFilters { public static function connect($dsn, $username, $password) { - if (!empty($pdo)) { + if (!empty(self::$pdo)) { throw new \Exception('Create Pdo only once'); } - self::$pdo = new \PDO($dsn, $username, $password); + self::$pdo = new \PDO($dsn, $username, $password, [\PDO::ATTR_PERSISTENT => true]); return self::$pdo; } public static function getPDOInstance() { - if (empty($pdo)) { + if (empty(self::$pdo)) { throw new \Exception('You must call connect() first'); } return self::$pdo;