DataObjects - staticGet not working as expected
| From: | Jeroen Houben | Date: | Wed, 10 Sep 2003 10:23:30 +0000 |
| Subject: | DataObjects - staticGet not working as expected | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-7683@lists.php.net to get a copy of this message | ||
Hi,
staticGet is not working the way I expect it to. In have a class "Contacts" generated by DataObjects. I have added a propery called x.
Consider the following code:
$contact_id = 73;
$contact =& PA_Contacts::staticGet($contact_id);
$contact->x = 'test';
echo "<p>this is property x of the contact: $contact->x</p>";
$contact =& PA_Contacts::staticGet($contact_id);
echo "<p>this is property x of the contact: $contact->x</p>";
This prints:
== start of output ==
STATIC GET - TRY CACHE PA_Contacts 73
STATIC GET - NOT IN CACHE PA_Contacts 73
GET contact_id 73 a:1:{i:0;s:10:"contact_id";}
__find 1
sql QUERYSELECT * FROM contacts WHERE contacts.contact_id = 73query DONE QUERY __find CHECK autofetchd 1 __find ABOUT TO AUTOFETCH fetchrow contacts DONE __find DONE this is property x of the contact: test STATIC GET - TRY CACHE PA_Contacts 73 this is property x of the contact: == end of output == How can that be? The 2nd time around it fetches the object from cache, but the property x is set to null, which makes me believe it's not the same object. I had a quick look at the sourcecode and on line 279 I came across this: $_DB_DATAOBJECT['CACHE'][$lclass][$key] = $obj; return $_DB_DATAOBJECT['CACHE'][$lclass][$key]; I thought this should be: $_DB_DATAOBJECT['CACHE'][$lclass][$key] =& $obj; return $_DB_DATAOBJECT['CACHE'][$lclass][$key]; But it doesn't work either... Any ideas? jeroen