I don’t know why YII has no way to add anything to a model attributes.
if there is a way please tell me. I spend a lot of time trying in vain.
Yes. I know you can add the attribute in the class like this:
class IR extends CActiveRecord
{
public newAttr = '';
public function afterFind(){
// give newAttr some value
}
}
and latter use it like : ir->newAttr
actually this is usefull, but not in all cases.
eg. I need to send the attributes including the virtual ones via ajax using JSON::encode
so I need to newAttr to be a part of the model’s attributes array. No way I could find to do so.
I used a very dirty way.
I added a new column to the database table whose name is newAttr.
that works for me.
but it’s dirty.