I love the dynamic __get() implementation in ActiveRecord that makes it possible to map db table column names to object properties. What I really love about it is the way CComponent’s __get() method makes it possible to create “dynamic” model attributes by defining getSomething() methods.
However, I’m now trying to create a “magic” get() method for an attribute that already represents one of my table’s columns (i.e. it is already in the model’s $_attributes array). So, the get() method I defined for this particular model never gets called because the first test in CActiveRecord::__get() (whether the single parameter passed to __get() exists in the $_attributes array) passes.
Is it possible to create a model method similar to the "magic" getSomething() methods, but for fields that do exist in the $_attributes array, so that in my view file, I can call $model->something to get the results of $model->getSomething(), just like I can do with fields that do not exists in the $_attributes array? If so, how is that done?
I had a little trouble articulating this. If it’s not clear, please ask me to clarify.
Thanks!
Tom