Hm, but I am wondering why do you need to handle non existing properties (fake fields) at all? oxuser__oxcountry property is not a good example because it is supposed never to be set from outside. If you need a country then you should handle only oxuser__oxcountryid (ID) field, you can set it and read it and it is always present. Additionally you can use oxCountry::getUserCountry() method which returns (afaik) country name. This is the only way to go. So not using oxuser__oxcountry property maybe is an answer to your question? :)
Regards Tomas Liubinas > -----Original Message----- > From: [email protected] [mailto:dev-general- > [email protected]] On Behalf Of Christopher Simon > Sent: Thursday, August 06, 2009 2:23 PM > To: [email protected] > Subject: Re: [oxid-dev-general] Bad behavior of the ORM > > Hi Tomas, > > i understand that it will be huge work to rewrite oxid until it uses real > getters and setters. > > But i wanted to adress an other problem which occurs because __get is > used, and __set don't. If you set a "virtual" property (e.g. a field which > not exists in database like oxcountry) by doing something like this: > > $oUser->oxuser__oxcountry = new oxField('value', T_RAW); > > PHP creates the property on $oUser as a public property. __get method is > not called on propertys, which are already existing on an object, > therefore the __get method is only called the first time the property gets > read. Then, it's called never again because the method getUserCountry sets > the Country value directly on the oxuser__oxcountry property. > > if you would use the __set magic method to set such virtual propertys like > oxcountry and ensure that the property is never set directly to the > object, according to ensure that the __get magic method is always called > when requesting values of virtual propertys, then the problem i > encountered wouldn't occur. > > It's a little bit hard to explain with e-mail :) > > > _______________________________________________ > 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
