ActiveRecord-Relation to Module-Model

Hi everybody,

i have some models in my app like ‘file’ and in the database file has a column creator_id.

On other hand i am using yii-user-module. Now i’d like to make a relationship between file and user.

how do i do this?

i tried following in my file-model, but didn’t help:




	public function relations()

	{

		// NOTE: you may need to adjust the relation name and the related

		// class name for the relations automatically generated below.

		return array(

                        'user' => array(self::BELONGS_TO, 'modules.user.User', 'user_id'),

		);

	}



thx

no idea?




	public function relations()

	{

		Yii::import('application.modules.user.models.*');

		return array(

                        'user' => array(self::BELONGS_TO, 'User', 'user_id'),

		);

	}






Yii::app()->getModule('user');



have a look here: http://blog.mbischof.de/models-aus-modulen-verwenden

thx, i think this will help. I’ll try it later and report it.

it worked! thx again.

MBI — What if you’re going the other way? I want to get a module model to make a relationship with a model from the main structure. How do I import the main structure? Or do I need to?

Thanks!

Bill

nothing to do for getting model from the main structure

Hi,

I am new to Yii Framework and need help with the same thing. Although the link mentioned in the previous messages with the answer is no longer available or does not open for me. Could someone please guide me to some other place with the same answer.

Ashish.

Replying to my own question, came across http://www.yiiframework.com/forum/index.php/topic/10555-relation-to-a-module-model/page__p__51866__hl__module+.model+#entry51866 and am adding

Yii::app()->getModule(‘user’);

to the relations function