Yii Framework Forum: Relation to a module model - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Relation to a module model Rate Topic: -----

#1 User is offline   Drewniacki 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 37
  • Joined: 19-July 10
  • Location:GdaƄsk, Poland

Posted 19 July 2010 - 02:52 PM

I am using a User module which provides a model for managing users (stored in: /protected/modules/user/models/User.php). In my own Article model I have a field author_id which refers to the User model from a User module (tricky, huh?).

How do I add a relation for this in my model? I have tried
'author' => array(self::BELONGS_TO, 'User', 'author_id')

but it raises PHP Error
include(User.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory

0

#2 User is offline   mbi 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 608
  • Joined: 08-May 09

Posted 19 July 2010 - 03:39 PM

whether you import the user model class or the whole module
Yii::import('path.to.userModel');
Yii::app()->getModule('user');

0

#3 User is offline   guillemweb 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 12-May 14

Posted 12 May 2014 - 04:11 AM

thanks for your help mbi!
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users