diff --git a/UPGRADE.md b/UPGRADE.md index 2d5e11b6018..8719658d65b 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -357,6 +357,7 @@ Every non-abstract schema manager class must implement them in order to satisfy # BC Break: The number of affected rows is returned as `int|string` The signatures of the methods returning the number of affected rows changed as returning `int|string` instead of `int`. +If the number is greater than `PHP_INT_MAX`, the number of affected rows may be returned as a string if the driver supports it. # BC Break: Dropped support for `collate` option for MySQL diff --git a/src/Driver/Connection.php b/src/Driver/Connection.php index 7af48ab52ba..f5229a2d298 100644 --- a/src/Driver/Connection.php +++ b/src/Driver/Connection.php @@ -36,6 +36,8 @@ public function quote(string $value): string; /** * Executes an SQL statement and return the number of affected rows. + * If the number of affected rows is greater than the maximum int value (PHP_INT_MAX), + * the number of affected rows may be returned as a string. * * @throws Exception */ diff --git a/src/Driver/OCI8/Connection.php b/src/Driver/OCI8/Connection.php index 3652ca0eb85..49923828aa2 100644 --- a/src/Driver/OCI8/Connection.php +++ b/src/Driver/OCI8/Connection.php @@ -78,7 +78,7 @@ public function quote(string $value): string * @throws Exception * @throws Parser\Exception */ - public function exec(string $sql): int|string + public function exec(string $sql): int { return $this->prepare($sql)->execute()->rowCount(); } diff --git a/src/Driver/PDO/Connection.php b/src/Driver/PDO/Connection.php index 7446b4a1d08..33e298079c4 100644 --- a/src/Driver/PDO/Connection.php +++ b/src/Driver/PDO/Connection.php @@ -21,7 +21,7 @@ public function __construct(private readonly PDO $connection) $connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } - public function exec(string $sql): int|string + public function exec(string $sql): int { try { $result = $this->connection->exec($sql); diff --git a/src/Driver/SQLSrv/Connection.php b/src/Driver/SQLSrv/Connection.php index 44629ec5f04..71050f17a3e 100644 --- a/src/Driver/SQLSrv/Connection.php +++ b/src/Driver/SQLSrv/Connection.php @@ -49,7 +49,7 @@ public function quote(string $value): string return "'" . str_replace("'", "''", $value) . "'"; } - public function exec(string $sql): int|string + public function exec(string $sql): int { $stmt = sqlsrv_query($this->connection, $sql);