A
A
arab7892015-04-02 16:15:14
Yii
arab789, 2015-04-02 16:15:14

Yii. relations. How to make a connection?

There is a user module, it has a User model. I am commenting and need to link to the users table. I make the connection in the admin module in the Comment model. Help please, how to do this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Dozhdikov, 2015-04-02
@arab789

In the Model Comment.php method:

public function relations()
{
    return array(
         'Users' => array(self::BELONGS_TO, 'User', 'user_id'),
    );
}

And in the description of the AdminModule.php module, the method:
public function init()
{
    $this->setImport(array(
        'user.models.*', // Импорт всех моделей из модуля user
    ));
}

If you need to receive comments from the user module, then do an analogy with this module.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question