ID:               43717
 Comment by:       crocodile2u at yandex dot ru
 Reported By:      tohru at nakarika dot com
 Status:           Open
 Bug Type:         PDO related
 Operating System: FreeBSD 6.1-RELEASE-p10
 PHP Version:      5.2.5
 New Comment:

I'm experiencing the same problem with yesterday (2008-03-31) snapshot
of php-5.3 and Kubuntu linux 7.10. By now, I have to workaround this by
doing some additional checks, but I am quite sure that this behavior is
more like a bug than a feature.


Previous Comments:
------------------------------------------------------------------------

[2007-12-31 09:22:22] tohru at nakarika dot com

Description:
------------
when you call PDOStatement::fetch() with the fetch mode
PDO::FETCH_CLASS 
PDO will create FooClass' instance.
And in the creation process PDO (or script engine?) calls
__set() method before calling FooClass' __construct().

Reproduce code:
---------------
class FooClass
{
  public function __construct($param)
  {
    echo "FooClass::constructor\n";
  }

  protected function &__set($name, $value)
  {
    echo "FooClass::__set()\n";
  }
}

$pdo = new PDO($dsn, ...);
$stmt = $pdo->prepare('SELECT * FROM ...');
$stmt->setFetchMode(PDO::FETCH_CLASS, FooClass, array('bar'));
$fooInst = $stmt->fetch();


Expected result:
----------------
The script should output strings in the following order:
1. FooClass::constructor
2. FooClass::__set()

Actual result:
--------------
1. FooClass::__set()
2. FooClass::constructor



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=43717&edit=1

Reply via email to