From: Ilia Alshanetsky Date: Wed, 31 Oct 2007 12:58:24 +0000 (+0000) Subject: MFB: Fixed bug #43139 PDO ignores ATTR_DEFAULT_FETCH_MODE in some cases with X-Git-Tag: php-5.2.5RC2~13 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f4cd343b6c8be9469c21b7b822d4d3c858cf158f;p=php MFB: Fixed bug #43139 PDO ignores ATTR_DEFAULT_FETCH_MODE in some cases with fetchAll() --- diff --git a/NEWS b/NEWS index a3542e7bca..0fc67a7707 100644 --- a/NEWS +++ b/NEWS @@ -40,6 +40,8 @@ PHP NEWS - Fixed htmlentities/htmlspecialchars not to accept partial multibyte sequences. (Stas) +- Fixed bug #43139 (PDO ignores ATTR_DEFAULT_FETCH_MODE in some cases with + fetchAll()). (Ilia) - Fixed bug #43130 (Bound parameters cannot have - in their name). (Ilia) - Fixed bug #43099 (XMLWriter::endElement() does not check # of params). (Ilia) diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c index 7b94820986..2cc2428755 100755 --- a/ext/pdo/pdo_stmt.c +++ b/ext/pdo/pdo_stmt.c @@ -1546,6 +1546,10 @@ static PHP_METHOD(PDOStatement, fetchAll) } } + if ((how & ~PDO_FETCH_FLAGS) == PDO_FETCH_USE_DEFAULT) { + how |= stmt->default_fetch_type & ~PDO_FETCH_FLAGS; + } + if (!error) { PDO_STMT_CLEAR_ERR(); MAKE_STD_ZVAL(data); diff --git a/ext/pdo/tests/bug_43139.phpt b/ext/pdo/tests/bug_43139.phpt new file mode 100644 index 0000000000..04b9bf311e --- /dev/null +++ b/ext/pdo/tests/bug_43139.phpt @@ -0,0 +1,34 @@ +--TEST-- +PDO Common: Bug #43139 (PDO ignore ATTR_DEFAULT_FETCH_MODE in some cases with fetchAll()) +--SKIPIF-- + +--FILE-- +setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); +$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING); + +var_dump($db->query('select 0 as abc, 1 as xyz, 2 as def')->fetchAll(PDO::FETCH_GROUP)); +?> +--EXPECT-- +array(1) { + [0]=> + array(1) { + [0]=> + array(2) { + ["xyz"]=> + string(1) "1" + ["def"]=> + string(1) "2" + } + } +}