relations() INNER JOIN

Hello guys!

I have three tables;

*Commands (Log_id)

*Log (User_id)


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:



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


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


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

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

(I hope I got it right)


Edit: didn't notice Qiangs answer before posting.

$commandList is an array… Others are correct.