diff --git a/UPGRADING b/UPGRADING index adfe422d90ab..95082ac45ae3 100644 --- a/UPGRADING +++ b/UPGRADING @@ -180,6 +180,10 @@ PHP 8.7 UPGRADE NOTES - MBString: . Improved performance of mb_strlen for UTF-8 strings. +- PDO: + . Improved performance of fetching rows with PDO::FETCH_BOTH, the default + fetch mode, for results with more than 4 columns. + - PDO_PGSQL: . Improved performance of the SQL parser that handles placeholders in PDO::prepare() and, with emulated prepares, PDOStatement::execute(). diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c index eab4398a0d5e..2a84d7ae2e98 100644 --- a/ext/pdo/pdo_stmt.c +++ b/ext/pdo/pdo_stmt.c @@ -735,7 +735,8 @@ static bool do_fetch(pdo_stmt_t *stmt, zval *return_value, enum pdo_fetch_type h case PDO_FETCH_NUM: case PDO_FETCH_NAMED: if (!group_key) { - array_init_size(return_value, stmt->column_count); + /* PDO::FETCH_BOTH stores every value under its name and its index */ + array_init_size(return_value, how == PDO_FETCH_BOTH ? 2 * stmt->column_count : stmt->column_count); } else { array_init(return_value); }