From:             [EMAIL PROTECTED]
Operating system: 
PHP version:      5.3CVS-2008-10-14 (CVS)
PHP Bug Type:     PDO related
Bug description:  PDO::setFetchMode() shouldn't requires the 2nd arg when using 
FETCH_CLASSTYPE

Description:
------------
See below.

Reproduce code:
---------------
<?php

$pdoDb = new
PDO('mysql:dbname=test;unix_socket=/var/run/mysqld/mysqld.sock', 'HELLO',
'WORLD :)', array(PDO::ATTR_EMULATE_PREPARES => false));

class myclass implements Serializable {
        public function __construct() {
                printf("%s()\n", __METHOD__);
        }
        
        public function serialize() {
                printf("%s()\n", __METHOD__);
                return "any data from serialize()";
        }
        
        public function unserialize($dat) {
                printf("%s(%s)\n", __METHOD__, var_export($dat, true));
                return $dat;
        }
}

class myclass2 extends myclass { }

$stmt = $pdoDb->prepare("SELECT * FROM testz");
var_dump($stmt->setFetchMode(PDO::FETCH_CLASS | PDO::FETCH_CLASSTYPE |
PDO::FETCH_GROUP));
$stmt->execute();

var_dump($stmt->fetch());
var_dump($stmt->fetch());

var_dump($stmt->fetchAll());


Expected result:
----------------
bool(true)
myclass::__construct()
object(myclass)#3 (1) {
  ["bar"]=>
  string(1) "1"
}
myclass::__construct()
object(myclass2)#3 (1) {
  ["bar"]=>
  string(1) "1"
}
array(0) {
}
[felipe php5]$ sapi/cli/php ~/public_html/bug.php 
bool(true)
myclass::__construct()
object(myclass)#3 (1) {
  ["bar"]=>
  string(1) "1"
}
myclass::__construct()
object(myclass2)#3 (1) {
  ["bar"]=>
  string(1) "1"
}
myclass::__construct()
array(1) {
  [0]=>
  object(myclass)#3 (1) {
    ["bar"]=>
    NULL
  }
}


Actual result:
--------------
bool(false)
array(4) {
  ["name"]=>
  string(7) "myclass"
  [0]=>
  string(7) "myclass"
  ["bar"]=>
  string(1) "1"
  [1]=>
  string(1) "1"
}
array(4) {
  ["name"]=>
  string(8) "myclass2"
  [0]=>
  string(8) "myclass2"
  ["bar"]=>
  string(1) "1"
  [1]=>
  string(1) "1"
}
array(1) {
  [0]=>
  array(4) {
    ["name"]=>
    string(7) "myclass"
    [0]=>
    string(7) "myclass"
    ["bar"]=>
    NULL
    [1]=>
    NULL
  }
}


-- 
Edit bug report at http://bugs.php.net/?id=46292&edit=1
-- 
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=46292&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): 
http://bugs.php.net/fix.php?id=46292&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=46292&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=46292&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=46292&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=46292&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=46292&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=46292&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=46292&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=46292&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=46292&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=46292&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=46292&r=globals
PHP 4 support discontinued:   http://bugs.php.net/fix.php?id=46292&r=php4
Daylight Savings:             http://bugs.php.net/fix.php?id=46292&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=46292&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=46292&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=46292&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=46292&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=46292&r=mysqlcfg

Reply via email to