【发布时间】:2014-08-20 18:42:03
【问题描述】:
Yii Active Record 如何在 DataProvider 中为 每个 模型安装场景?
public function searchView()
{
$criteria = new CDbCriteria([
'select' => 'last_comment,name,data,cdate,mdate,edate,coperator,eoperator',
'with' => ['houses', 'houses.city', 'houses.district', 'houses.street','stages']
]);
$model = $this;
//$model->scenario = 'searchView'; this is for dataprovider
return new CActiveDataProvider($model , [
'criteria' => $criteria,
'sort' => [
'defaultOrder' => 'cdate DESC'
],
'pagination' => $this->searchFrom || $this->searchTo || $this->district_key || $this->city_key ? false : ['pageSize' => 100]
])
;
}
【问题讨论】:
标签: php database activerecord yii