From 44045f8cb1fa2ac057c14b8f9a16b0692f34278e Mon Sep 17 00:00:00 2001 From: Ilia Alshanetsky Date: Mon, 4 Dec 2006 02:40:08 +0000 Subject: [PATCH] Fixed bug #38252 (Incorrect PDO error message on invalid default fetch mode). --- NEWS | 2 ++ ext/pdo/pdo_dbh.c | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/NEWS b/NEWS index 11c0cf915a0..1f4e0dbfaa9 100644 --- a/NEWS +++ b/NEWS @@ -131,6 +131,8 @@ PHP NEWS (Dmitry) - Fixed bug #38456 (Apache2 segfaults when virtual() is called in .php ErrorDocument). (Ilia) +- Fixed bug #38252 (Incorrect PDO error message on invalid default fetch + mode). (Ilia) - Fixed bug #37773 (iconv_substr() gives "Unknown error" when string length = 1"). (Ilia) - Fixed bug #36975 (natcasesort() causes array_pop() to misbehave). (Hannes) diff --git a/ext/pdo/pdo_dbh.c b/ext/pdo/pdo_dbh.c index 45df0b12216..5bbeec3eae9 100755 --- a/ext/pdo/pdo_dbh.c +++ b/ext/pdo/pdo_dbh.c @@ -706,6 +706,15 @@ static int pdo_dbh_attribute_set(pdo_dbh_t *dbh, long attr, zval *value TSRMLS_D return SUCCESS; case PDO_ATTR_DEFAULT_FETCH_MODE: + if (Z_TYPE_P(value) == IS_ARRAY) { + zval **tmp; + if (zend_hash_index_find(Z_ARRVAL_P(value), 0, (void**)&tmp) == SUCCESS && Z_TYPE_PP(tmp) == IS_LONG) { + if (Z_LVAL_PP(tmp) == PDO_FETCH_INTO || Z_LVAL_PP(tmp) == PDO_FETCH_CLASS) { + pdo_raise_impl_error(dbh, NULL, "HY000", "FETCH_INTO and FETCH_CLASS are not yet supported as default fetch modes" TSRMLS_CC); + return FAILURE; + } + } + } convert_to_long(value); if (Z_LVAL_P(value) == PDO_FETCH_USE_DEFAULT) { pdo_raise_impl_error(dbh, NULL, "HY000", "invalid fetch mode type" TSRMLS_CC);