relations() INNER JOIN

Hello guys!

I have three tables;

*Commands (Log_id)

*Log (User_id)

*User

I wish I could find Commands together Log and respective log Users.

I wish I could do it at Commands controller.

How could I configure with() method to return it? How could I return User data with Log data?

Assuming you have set up the relations() method, you can do the following:

$commands=Commands::model()->with('log.user')->findAll();

Commands.php:

'log'=>array(self::BELONGS_TO, 'Log', 'Log_id'),

Log.php:

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

CommandController.php:

$commandList = Commands::model()->with(log, log.user)->findall()

echo $commandList->log->user->someAttribute

(I hope I got it right)

/Tommy

Edit: didn't notice Qiangs answer before posting.

$commandList is an array… Others are correct.