note 101081 modified in pdostatement.fetch by danbrown

From: Date: Thu, 25 Nov 2010 16:12:08 +0000
Subject: note 101081 modified in pdostatement.fetch by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-174356@lists.php.net to get a copy of this message
When fetching an object, the constructor of the class is called after the fields are populated by default. PDO::FETCH_PROPS_LATE is used to change the behaviour and make it work as expected - constructor be called _before_ the object fields will be populated with the data. sample: <?php $a = $PDO->query('select id from table'); $a->setFetchMode(PDO::FETCH_CLASS|PDO::FETCH_PROPS_LATE, 'ClassName'); $obj = $a->fetch(); ?> http://bugs.php.net/bug.php?id=53394 --was-- When fetching an object, the constructor of the class is called after the fields are populated by default. PDO::FETCH_PROPS_LATE is used to change the behaviour and make it work as expected - constructor be called _before_ the object fields will be populated with the data. sample: $a = $PDO->query('select id from table'); $a->setFetchMode(PDO::FETCH_CLASS|PDO::FETCH_PROPS_LATE, 'ClassName'); $obj = $a->fetch(); http://bugs.php.net/bug.php?id=53394 http://php.net/manual/en/pdostatement.fetch.php

« previous php.notes (#174356) next »