我在实体模型中定义了以下关系:
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(
...
'profile' => array(self::BELONGS_TO, 'Profile', 'userId'),
...
它"编译"成LEFT OUTER JOIN。但我可以保证,每个实体都有相关的概要文件,所以LEFT OUTER JOIN在这种情况下是多余的,可能会影响一些性能。如何强制将此关系编译为简单的JOIN(INNER JOIN)?
您可以在与joinType
的关系中指定连接类型,如下所示:
return array(
...
'profile' => array(self::BELONGS_TO, 'Profile', 'userId','joinType'=>'INNER JOIN'),
...