我按照文档中的说明配置了 Yii cactivedataprovider:
$criteria = new CDbCriteria();
$criteria->together = true;
$criteria->with = array(
'relationId0',
'relationId1',
...
);
$criteria->compare('"relationId0".property0', $this->relationId0_property0, true);
return new CActiveDataProvider($this, array(
'criteria' => $criteria,
'sort' => array(
'attributes' => array(
...
'relationId0.property0' => array(
'asc' => '"relationId0".property0',
'desc' => '"relationId0".property0 DESC',
),
...
)
)
));
因此,当 ->together 为 false 时,gridview 正常工作并获取分页允许的所有行,但在这种情况下,比较(所以搜索)不起作用(因为这种方式不使用 sql 查询中的相关对象),
但是当 ->together 为真(据说这是解决方案)时,比较正在工作,但 gridview 在每页中获得随机数的行。
感谢您的帮助。