Bug #67710 [NEW]: PDOStatement::fetch not work for parent class private properties
| From: | oleg dot nucer at gmail dot com | Date: | Tue, 29 Jul 2014 18:47:54 +0000 |
| Subject: | Bug #67710 [NEW]: PDOStatement::fetch not work for parent class private properties | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-186866@lists.php.net to get a copy of this message | ||
From: oleg dot nucer at gmail dot com
Operating system: Windows 8
PHP version: 5.6.0RC2
Package: PDO Core
Bug Type: Bug
Bug description:PDOStatement::fetch not work for parent class private properties
Description:
------------
PDOStatement::fetch with PDO::FETCH_CLASS works fine, until I tried to
use it with parent class private properties... See the test script.
Test script:
---------------
class Animal
{
private $color;
public function getColor()
{
return $this->color;
}
}
class Cat extends Animal
{
}
$statement->setFetchMode(PDO::FETCH_CLASS, "Cat" );
$someCat = $statement->fetch();
echo $someCat->getColor(); //empty
print_r( $someCat );
/*
now have strange output like:
[color:Animal:private] =>
[color] => grey
*/
Expected result:
----------------
All private properties of parent class have to be set same way as public
and protected ones.
Actual result:
--------------
Private property of parent class still empty :(
--
Edit bug report at https://bugs.php.net/bug.php?id=67710&edit=1
--