summaryrefslogtreecommitdiff
path: root/ext/pdo/pdo_stmt.c
diff options
context:
space:
mode:
authorFelipe Pena <felipe@php.net>2008-10-14 17:36:02 +0000
committerFelipe Pena <felipe@php.net>2008-10-14 17:36:02 +0000
commit84be2eb47b9512d257f9816dc5adef792e275294 (patch)
treec48b67e0cbfb080a6642615db859ffc71d3f9495 /ext/pdo/pdo_stmt.c
parent3d615717096201643d8be3d9f40a71bdbf9f8160 (diff)
downloadphp-git-84be2eb47b9512d257f9816dc5adef792e275294.tar.gz
- MFH: Fixed bug #46292 (PDO::setFetchMode() shouldn't requires the 2nd arg when using FETCH_CLASSTYPE)
Diffstat (limited to 'ext/pdo/pdo_stmt.c')
-rwxr-xr-xext/pdo/pdo_stmt.c38
1 files changed, 24 insertions, 14 deletions
diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c
index 5cea7db43c..01020c69a3 100755
--- a/ext/pdo/pdo_stmt.c
+++ b/ext/pdo/pdo_stmt.c
@@ -1941,7 +1941,7 @@ static PHP_METHOD(PDOStatement, getColumnMeta)
int pdo_stmt_setup_fetch_mode(INTERNAL_FUNCTION_PARAMETERS, pdo_stmt_t *stmt, int skip)
{
long mode = PDO_FETCH_BOTH;
- int argc = ZEND_NUM_ARGS() - skip;
+ int flags, argc = ZEND_NUM_ARGS() - skip;
zval ***args;
zend_class_entry **cep;
@@ -1974,6 +1974,7 @@ fail_out:
convert_to_long_ex(args[skip]);
mode = Z_LVAL_PP(args[skip]);
+ flags = mode & PDO_FETCH_FLAGS;
if (!pdo_stmt_verify_mode(stmt, mode, 0 TSRMLS_CC)) {
efree(args);
@@ -2001,21 +2002,30 @@ fail_out:
break;
case PDO_FETCH_CLASS:
- if (argc < 2 || argc > 3) {
- goto fail_out;
- }
- convert_to_string_ex(args[skip+1]);
-
- if (FAILURE == zend_lookup_class(Z_STRVAL_PP(args[skip+1]),
- Z_STRLEN_PP(args[skip+1]), &cep TSRMLS_CC)) {
- goto fail_out;
- }
+ /* Gets its class name from 1st column */
+ if ((flags & PDO_FETCH_CLASSTYPE) == PDO_FETCH_CLASSTYPE) {
+ if (argc != 1) {
+ goto fail_out;
+ }
+ stmt->fetch.cls.ce = NULL;
+ } else {
+ if (argc < 2 || argc > 3) {
+ goto fail_out;
+ }
+ convert_to_string_ex(args[skip+1]);
- if (!cep || !*cep) {
- goto fail_out;
+ if (FAILURE == zend_lookup_class(Z_STRVAL_PP(args[skip+1]),
+ Z_STRLEN_PP(args[skip+1]), &cep TSRMLS_CC)) {
+ goto fail_out;
+ }
+
+ if (!cep || !*cep) {
+ goto fail_out;
+ }
+
+ stmt->fetch.cls.ce = *cep;
}
-
- stmt->fetch.cls.ce = *cep;
+
stmt->fetch.cls.ctor_args = NULL;
#ifdef ilia_0 /* we'll only need this when we have persistent statements, if ever */
if (stmt->dbh->is_persistent) {