Hello,
You should not use setting object parameters like this:
$oUser->oxuser__oxcountry->value = 'test'
This is why "oxuser__oxcountry" was set to an empty string.
For setting object parameters you should use oxField class
$oUser->oxuser__oxcountry = new oxField( 'test', oxField::T_RAW);
----- Original Message -----
From: "Christopher Simon" <[email protected]>
To: <[email protected]>
Sent: Wednesday, August 05, 2009 8:16 PM
Subject: [oxid-dev-general] Bad behavior of the ORM
Hi there,
i've noticed that OXID uses magic-getters, but no magic-setters. I'll
explain the problem with an example:
the field "oxuser__oxcountry" is retrieved by the __get function, if its
not already existing. But, if it's set once directly with an line like
this "$oUser->oxuser__oxcountry->value = 'test';" the magic getter remains
uncalled, because the property already exits on $oUser.
Because of this behavior i had trouble with the efire paypal module.
Somewhere "oxuser__oxcountry" was set to an empty string (i didn't found
the spot yet), and therefore, Paypal recieved no Country and an error was
thrown.
But there is some other misbehavior caused by this: If you once read
oxuser__oxcountry, the metho "getUserCountry()" sets user country directy
on this property. But if user countryId changes in the meantime,
"$oUser->oxuser__oxcountry->value" will remain untouched because it never
gets an update.
In general, working with object propertys directly is very very dirty. For
error prevention in OXID 4 the magic setters should be utilized as soon as
possible. But for OXID 5, i would like to see OXID to utilize real getters
and setters and retrieve values like this:
$oUser->getCountryName() and set Values like this
$oUser->setCountryName($value);
This would be more OOP-Style, and more suitable for all module developers
out there, because the "getDatabaseField" methods could be extended, too.
For dynamic field adding, you could use the "__call" magic method.
_______________________________________________
dev-general mailing list
[email protected]
http://dir.gmane.org/gmane.comp.php.oxid.general
_______________________________________________
dev-general mailing list
[email protected]
http://dir.gmane.org/gmane.comp.php.oxid.general