#46292 [Asn->Csd]: PDO::setFetchMode() shouldn't requires the 2nd arg when using FETCH_CLASSTYPE
| From: | felipe@php.net | Date: | Tue, 14 Oct 2008 17:53:42 +0000 |
| Subject: | #46292 [Asn->Csd]: PDO::setFetchMode() shouldn't requires the 2nd arg when using FETCH_CLASSTYPE | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-129692@lists.php.net to get a copy of this message | ||
ID: 46292
Updated by: felipe@php.net
Reported By: felipe@php.net
-Status: Assigned
+Status: Closed
Bug Type: PDO related
PHP Version: 5.3CVS-2008-10-14 (CVS)
Assigned To: felipe
New Comment:
This bug has been fixed in CVS.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
Thank you for the report, and for helping us make PHP better.
Fixed in 5.2.7, 5.3 and HEAD.
Previous Comments:
------------------------------------------------------------------------
[2008-10-14 15:57:43] felipe@php.net
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 this bug report at http://bugs.php.net/?id=46292&edit=1