我在实体模型中定义了以下关系:
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'),
...
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句