Use relations in a CActiveRecordBehavior?

Can a CActiveRecordBehavior method access a relation of the CActiveRecord it is attached to? If so, how? Using $this->relationName gives me CException: Property "TheBehavior.relationName" is not defined.

I would try $this->owner->relationName.


Super. Thanks Tommy.

I’m still learning. While a Yii behavior is a bit like adding methods to a class, it’s not like adding them in an OO language like JS. $this is the behavior class instance, not the model the behavior was attached to.