felipe          Fri Oct 10 16:48:14 2008 UTC

  Modified files:              (Branch: PHP_5_2)
    /php-src/ext/pdo    pdo_stmt.c 
  Log:
  MFH:
  - Fixed bug #46139 (PDOStatement->setFetchMode() forgets FETCH_PROPS_LATE)
    Initial patch by: chsc at peytz dot dk
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/pdo/pdo_stmt.c?r1=1.118.2.38.2.36&r2=1.118.2.38.2.37&diff_format=u
Index: php-src/ext/pdo/pdo_stmt.c
diff -u php-src/ext/pdo/pdo_stmt.c:1.118.2.38.2.36 
php-src/ext/pdo/pdo_stmt.c:1.118.2.38.2.37
--- php-src/ext/pdo/pdo_stmt.c:1.118.2.38.2.36  Tue Sep 23 23:10:01 2008
+++ php-src/ext/pdo/pdo_stmt.c  Fri Oct 10 16:48:13 2008
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: pdo_stmt.c,v 1.118.2.38.2.36 2008/09/23 23:10:01 felipe Exp $ */
+/* $Id: pdo_stmt.c,v 1.118.2.38.2.37 2008/10/10 16:48:13 felipe Exp $ */
 
 /* The PDO Statement Handle Class */
 
@@ -891,7 +891,7 @@
 static int do_fetch(pdo_stmt_t *stmt, int do_bind, zval *return_value,
        enum pdo_fetch_type how, enum pdo_fetch_orientation ori, long offset, 
zval *return_all TSRMLS_DC) /* {{{ */
 {
-       int flags = how & PDO_FETCH_FLAGS, idx, old_arg_count = 0;
+       int flags, idx, old_arg_count = 0;
        zend_class_entry *ce = NULL, *old_ce = NULL;
        zval grp_val, *grp, **pgrp, *retval, *old_ctor_args = NULL;
        int colno;
@@ -899,6 +899,7 @@
        if (how == PDO_FETCH_USE_DEFAULT) {
                how = stmt->default_fetch_type;
        }
+       flags = how & PDO_FETCH_FLAGS;
        how = how & ~PDO_FETCH_FLAGS;
 
        if (!do_fetch_common(stmt, ori, offset, do_bind TSRMLS_CC)) {
@@ -1473,7 +1474,7 @@
        zval *arg2;
        zend_class_entry *old_ce;
        zval *old_ctor_args, *ctor_args = NULL;
-       int error = 0, old_arg_count;
+       int error = 0, flags, old_arg_count;
        PHP_STMT_GET_OBJ;         
 
        if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|lzz", 
&how, &arg2, &ctor_args)) {
@@ -1565,7 +1566,10 @@
                }
        }
 
+       flags = how & PDO_FETCH_FLAGS;
+       
        if ((how & ~PDO_FETCH_FLAGS) == PDO_FETCH_USE_DEFAULT) {
+               flags |= stmt->default_fetch_type & PDO_FETCH_FLAGS;
                how |= stmt->default_fetch_type & ~PDO_FETCH_FLAGS;
        }
 
@@ -1580,7 +1584,7 @@
                } else {
                        return_all = 0;
                }
-               if (!do_fetch(stmt, TRUE, data, how, PDO_FETCH_ORI_NEXT, 0, 
return_all TSRMLS_CC)) {
+               if (!do_fetch(stmt, TRUE, data, how | flags, 
PDO_FETCH_ORI_NEXT, 0, return_all TSRMLS_CC)) {
                        FREE_ZVAL(data);
                        error = 2;
                }
@@ -1589,15 +1593,15 @@
                if ((how & PDO_FETCH_GROUP)) {
                        do {
                                MAKE_STD_ZVAL(data);
-                       } while (do_fetch(stmt, TRUE, data, how, 
PDO_FETCH_ORI_NEXT, 0, return_all TSRMLS_CC));
+                       } while (do_fetch(stmt, TRUE, data, how | flags, 
PDO_FETCH_ORI_NEXT, 0, return_all TSRMLS_CC));
                } else if (how == PDO_FETCH_KEY_PAIR || (how == 
PDO_FETCH_USE_DEFAULT && stmt->default_fetch_type == PDO_FETCH_KEY_PAIR)) {
-                       while (do_fetch(stmt, TRUE, data, how, 
PDO_FETCH_ORI_NEXT, 0, return_all TSRMLS_CC));
+                       while (do_fetch(stmt, TRUE, data, how | flags, 
PDO_FETCH_ORI_NEXT, 0, return_all TSRMLS_CC));
                } else {
                        array_init(return_value);
                        do {
                                add_next_index_zval(return_value, data);
                                MAKE_STD_ZVAL(data);
-                       } while (do_fetch(stmt, TRUE, data, how, 
PDO_FETCH_ORI_NEXT, 0, 0 TSRMLS_CC));
+                       } while (do_fetch(stmt, TRUE, data, how | flags, 
PDO_FETCH_ORI_NEXT, 0, 0 TSRMLS_CC));
                }
                FREE_ZVAL(data);
        }



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to