iliaa           Wed Oct 31 12:58:39 2007 UTC

  Modified files:              
    /php-src/ext/pdo/tests      bug_43139.phpt 
    /php-src/ext/pdo    pdo_stmt.c 
  Log:
  
  MFB: Fixed bug #43139 PDO ignores ATTR_DEFAULT_FETCH_MODE in some cases with
  fetchAll()
  
http://cvs.php.net/viewvc.cgi/php-src/ext/pdo/tests/bug_43139.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/pdo/tests/bug_43139.phpt
diff -u /dev/null php-src/ext/pdo/tests/bug_43139.phpt:1.2
--- /dev/null   Wed Oct 31 12:58:39 2007
+++ php-src/ext/pdo/tests/bug_43139.phpt        Wed Oct 31 12:58:39 2007
@@ -0,0 +1,34 @@
+--TEST--
+PDO Common: Bug #43139 (PDO ignore ATTR_DEFAULT_FETCH_MODE in some cases with 
fetchAll())
+--SKIPIF--
+<?php # vim:ft=php
+if (!extension_loaded('pdo')) die('skip');
+$dir = getenv('REDIR_TEST_DIR');
+if (false == $dir) die('skip no driver');
+require_once $dir . 'pdo_test.inc';
+PDOTest::skip();
+?>
+--FILE--
+<?php
+if (getenv('REDIR_TEST_DIR') === false) 
putenv('REDIR_TEST_DIR='.dirname(__FILE__) . '/../../pdo/tests/');
+require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
+$db = PDOTest::factory();
+
+$db->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"
+    }
+  }
+}
http://cvs.php.net/viewvc.cgi/php-src/ext/pdo/pdo_stmt.c?r1=1.179&r2=1.180&diff_format=u
Index: php-src/ext/pdo/pdo_stmt.c
diff -u php-src/ext/pdo/pdo_stmt.c:1.179 php-src/ext/pdo/pdo_stmt.c:1.180
--- php-src/ext/pdo/pdo_stmt.c:1.179    Mon Oct  8 04:05:22 2007
+++ php-src/ext/pdo/pdo_stmt.c  Wed Oct 31 12:58:39 2007
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: pdo_stmt.c,v 1.179 2007/10/08 04:05:22 davidw Exp $ */
+/* $Id: pdo_stmt.c,v 1.180 2007/10/31 12:58:39 iliaa Exp $ */
 
 /* The PDO Statement Handle Class */
 
@@ -1236,7 +1236,7 @@
 }
 /* }}} */
 
-static int pdo_stmt_verify_mode(pdo_stmt_t *stmt, int mode, int fetch_all 
TSRMLS_DC) /* {{{ */
+static int pdo_stmt_verify_mode(pdo_stmt_t *stmt, long mode, int fetch_all 
TSRMLS_DC) /* {{{ */
 {
        int flags = mode & PDO_FETCH_FLAGS;
 
@@ -1522,6 +1522,10 @@
                }
        }
 
+       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);
@@ -1890,6 +1894,7 @@
                case PDO_FETCH_OBJ:
                case PDO_FETCH_BOUND:
                case PDO_FETCH_NAMED:
+               case PDO_FETCH_KEY_PAIR:
                        break;
 
                case PDO_FETCH_COLUMN:

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

Reply via email to