问:如何获取表的所有记录?
状态:我想导出该表的所有记录。现在,我可以导出该表的前10条记录了。我该怎么做?
这是我的模型
public function dashboard()
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria=new CDbCriteria;
$criteria->select = 't.*';
if (Yii::app()->user->checkAccess('Reviewer') || Yii::app()->user->checkAccess('Implementer'))
$criteria->join = "JOIN users u ON (t.creator = u.id)";
if($this->creator):
$criteria->compare('u.username',$this->creator);
else:
if (Yii::app()->user->checkAccess('Creator')):
$criteria->compare('t.creator',Yii::app()->user->id);
endif;
endif;
$criteria->compare('t.request_no',$this->request_no);
$criteria->compare('t.description',$this->description,'true');
if(isset($this->status)):
$criteria->addSearchCondition('t.status',$this->status, false);
endif;
if (Yii::app()->user->checkAccess('Reviewer')):
$criteria->addSearchCondition('t.reviewers',Yii::app()->user->id,true, 'OR');
endif;
if (Yii::app()->user->checkAccess('Implementer')):
$criteria->addSearchCondition('t.implementers',Yii::app()->user->id,true, 'OR');
endif;
//$criteria->order = ' created_date DESC';
$all = new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
$_SESSION['all'] = $all;
$data = new CActiveDataProvider(get_class($this), array(
'pagination'=>array('pageSize'=> Yii::app()->user->getState('pageSize',
Yii::app()->params['defaultPageSize']),),
'criteria'=>$criteria,
));
$_SESSION['limited'] = $data; // get all data and filtered data :)
return $data;
}
谢谢你的忠告
3条答案
按热度按时间azpvetkf1#
必须为数据提供程序设置禁用分页。为此,请将
pagination
属性设置为falseeulz3vhy2#
我找到了解决办法。
**get_class($this)**是解决这个问题的关键。
qxsslcnc3#
在Yii2中,以下仍然有效。