本文整理汇总了PHP中CActiveDataProvider::setPagination方法的典型用法代码示例。如果您正苦于以下问题:PHP CActiveDataProvider::setPagination方法的具体用法?PHP CActiveDataProvider::setPagination怎么用?PHP CActiveDataProvider::setPagination使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CActiveDataProvider
的用法示例。
在下文中一共展示了CActiveDataProvider::setPagination方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createDataArray
protected function createDataArray()
{
\Yii::beginProfile('createDataArray');
$data = [];
Yii::beginProfile('getData');
if (!$this->config['serverSide']) {
$paginator = $this->dataProvider->getPagination();
if ($this->dataProvider instanceof \CActiveDataProvider) {
$this->dataProvider->criteria->order = '';
}
$this->dataProvider->setPagination(false);
$source = $this->dataProvider->getData(true);
$this->dataProvider->setPagination($paginator);
} else {
$source = $this->dataProvider->getData();
}
Yii::endProfile('getData');
Yii::beginProfile('renderCells');
// Get column name map.
$names = array_map([$this, 'getColumnName'], $this->columns);
foreach ($source as $i => $r) {
$row = [];
foreach ($this->columns as $j => $column) {
$name = $names[$j];
$row[$name] = $column->getDataCellContent($i);
}
$metaRow = [];
if ($this->addMetaData !== false) {
Yii::beginProfile('addMetaData');
if (is_callable([$r, 'getKeyString'])) {
$metaRow['data-key'] = call_user_func([$r, 'getKeyString']);
}
if (is_array($this->addMetaData)) {
foreach ($this->addMetaData as $field) {
$metaRow["data-{$field}"] = \CHtml::value($r, $field);
}
}
Yii::endProfile('addMetaData');
}
if (isset($this->rowCssClassExpression)) {
$metaRow['class'] = $this->evaluateExpression($this->rowCssClassExpression, array('row' => $i, 'data' => $r));
}
$row['metaData'] = $metaRow;
$data[] = $row;
}
\Yii::endProfile('renderCells');
\Yii::endProfile('createDataArray');
return $data;
}
示例2: actionGridProduct
public function actionGridProduct()
{
$search = null;
$criteria = new CDbCriteria();
if (!empty($_POST)) {
$search = Util::input($_POST['search']);
$criteria->condition = "\n product_code LIKE(:search)\n OR product_name LIKE(:search)\n ";
$criteria->params = array('search' => '%' . $search . '%');
}
$product = new Product();
$model = new CActiveDataProvider($product, array('sort' => array('defaultOrder' => 'product_id DESC')));
$pagination = new CPagination();
$pagination->setPageSize(40);
$model->setPagination($pagination);
$model->setCriteria($criteria);
$this->render('//Dialog/GridProduct', array('model' => $model));
}
示例3: actionIndex
/**
* Lists all notes.
*/
public function actionIndex()
{
$model = new Note('search');
if (isset($_GET['Note'])) {
$model->attributes = $_GET['Note'];
$dataProvider = $model->search();
} else {
$dataProvider = new CActiveDataProvider('Note', array('criteria' => array('order' => 'upload_timestamp DESC')));
}
$dataProvider->setPagination(array('pageSize' => 16));
$students = Student::model()->findAll();
$usernames = array();
foreach ($students as $student) {
$usernames[] = $student->username;
}
$this->render('index', array('model' => $model, 'dataProvider' => $dataProvider, 'usernames' => $usernames));
}
示例4: actionIndex
public function actionIndex($id){
$this->initialize($id);
$editMode = $this->checkEditMode($id, Yii::app()->user->getId());
$lecture = Lecture::model()->findByPk($id);
$criteria = new CDbCriteria();
$criteria->addCondition('id_lecture='.$id);
$dataProvider = new CActiveDataProvider('LectureElement');
$dataProvider->criteria = $criteria;
$criteria->order = 'block_order ASC';
$dataProvider->setPagination(array(
'pageSize' => '200',
)
);
$owners = [];
$criteria1 = new CDbCriteria();
$criteria1->alias='teacher_module';
$criteria1->select = 'idTeacher';
$criteria1->addCondition('idModule='.$lecture->idModule);
$criteria1->toArray();
$temp = TeacherModule::model()->findAll($criteria1); //info about owners
for($i = 0; $i < count($temp);$i++){
array_push($owners, $temp[$i]->idTeacher);
}
$teachers = Teacher::model()->findAllByPk($owners);
$countBlocks = LectureElement::model()->count('id_lecture = :id', array(':id' => $id));
$this->render('index', array(
'dataProvider' => $dataProvider,
'lecture' => $lecture,
'editMode' => $editMode,
'countBlocks' => $countBlocks,
'teachers' => $teachers,
));
}
示例5: actionIndex
public function actionIndex()
{
$model = new Permissions('search');
if(isset($_GET['Permissions']))
$model->attributes=$_GET['Permissions'];
$dataProvider = new CActiveDataProvider('Permissions');
$dataProvider->setPagination(array(
'pageSize' => '50',
)
);
if(!isset($_GET['ajax'])) $this->render('index', array(
'dataProvider' => $dataProvider,
'model' => $model,
));
else $this->renderPartial('index', array(
'dataProvider' => $dataProvider,
'model' => $model,
));
}
示例6: actionGlobalExport
/**
* An AJAX called method to export module data.
*
* This method actually prepares all the data via recursive AJAX requests
* until all data has been exported. This exports each module into the CSV
* by class, using pagination to cut down on request time.
*
* @param string $model The name of the current model being exported
* @param int $page The page of data which the data provider's paginator is on
*/
public function actionGlobalExport($model, $page)
{
if (class_exists($model)) {
ini_set('memory_limit', -1);
$file = $this->safePath();
$fp = fopen($file, 'a+');
$tempModel = X2Model::model($model);
$meta = array_keys($tempModel->attributes);
$meta[] = $model;
if ($page == 0) {
fputcsv($fp, $meta);
}
// If we're on the first page for this model, need to add metadata.
$dp = new CActiveDataProvider($model, array('pagination' => array('pageSize' => 100)));
$pg = $dp->getPagination();
$pg->setCurrentPage($page);
// These two lines will set the data provider
$dp->setPagination($pg);
// paginator to the requested page of data
$records = $dp->getData();
$pageCount = $dp->getPagination()->getPageCount();
// Total number of pages
foreach ($records as $record) {
// Re-pack all unpacked attributes for writing to a file, so that
// they can be interpolated as strings:
foreach ($record->behaviors() as $name => $config) {
$behavior = $record->asa($name);
if ($behavior instanceof TransformedFieldStorageBehavior) {
$behavior->packAll();
$record->disableBehavior($name);
}
}
$tempAttributes = $tempModel->attributes;
$tempAttributes = array_merge($tempAttributes, $record->attributes);
if ($model == 'Profile') {
$tempAttributes['theme'] = json_encode($record->theme);
}
$tempAttributes[] = $model;
fputcsv($fp, $tempAttributes);
// Export the data to CSV
}
unset($tempModel, $dp);
fclose($fp);
if ($page + 1 < $pageCount) {
echo $page + 1;
// If there are still more pages to go, echo the next page number
}
}
}
示例7: getItemsForListCode
/**
* Get list items
* array returned consists of array(list_item_name_code => list_item_name, ...)
* @param $list_code
* @param bool $dropdown_array_source
* @return array
*/
public function getItemsForListCode($list_code, $dropdown_array_source = false)
{
$dataProvider = new CActiveDataProvider('SystemList', array('criteria' => array('condition' => "system_list_code = '" . $list_code . "' AND system_list_item_active = 1", 'order' => 'system_list_item_order ASC')));
if ($dropdown_array_source) {
$arr = array();
$dataProvider->setPagination(false);
$data = $dataProvider->getData();
foreach ($data as $item) {
$arr[$item->system_list_item_code] = $item->system_list_item_name;
}
return $arr;
}
// to get list of object
$dataProvider->setPagination(false);
return $dataProvider->getData();
}
示例8: getResultsBasedForReturnType
/**
* Based on requested return type, return the data
*
* @param CActiveDataProvider $dataProvider
* @param mixed $return_type
*/
function getResultsBasedForReturnType($dataProvider, $return_type = self::LB_QUERY_RETURN_TYPE_ACTIVE_DATA_PROVIDER)
{
switch ($return_type) {
case self::LB_QUERY_RETURN_TYPE_ACTIVE_DATA_PROVIDER:
return $dataProvider;
case self::LB_QUERY_RETURN_TYPE_MODELS_ARRAY:
$dataProvider->setPagination(false);
return $dataProvider->getData();
case self::LB_QUERY_RETURN_TYPE_DATASOURCE_JSON:
return $this->getResultsAsDatasourceJSON($dataProvider);
case self::LB_QUERY_RETURN_TYPE_DROPDOWN_ARRAY:
return $this->getResultsAsDropDownArray($dataProvider);
default:
return $dataProvider;
}
}
示例9: actionRecargasIngresadas
public function actionRecargasIngresadas()
{
$model = new Recarga('search');
$model->unsetAttributes();
$criteria = new CDbCriteria(array('condition' => 'usuario_id =:usuario_id', 'order' => 'id DESC', 'limit' => 500, 'params' => array(':usuario_id' => 1)));
$model = Recarga::model()->findAll($criteria);
$dataProvider = new CActiveDataProvider('Recarga', array('criteria' => $criteria));
$dataProvider->setPagination(false);
//FIN CONSULTA
$this->render('recargas_ingresadas', array('dataProvider' => $dataProvider, 'model' => $model));
}
示例10: getInvitesToAccount
/**
*
* @param unknown $account_id
* @param string $get_data
* @return <multitype: array,CActiveDataProvider>
*/
public function getInvitesToAccount($account_id, $get_data = false)
{
$account = Account::model()->findByPk($account_id);
$dataProvider = new CActiveDataProvider('AccountInvitation', array('criteria' => array('condition' => "account_invitation_to_email = '{$account->account_email}'")));
if ($get_data === true) {
$dataProvider->setPagination(false);
return $dataProvider->getData();
}
return $dataProvider;
}
示例11: getItemsList
public function getItemsList($list_code)
{
$dataProvider = new CActiveDataProvider('UserList', array('criteria' => array('condition' => "system_list_code = '" . $list_code . "'", 'order' => 'system_list_item_order ASC')));
$dataProvider->setPagination(false);
return $dataProvider->getData();
}
示例12: getAll
/**
* Retrieves a list of all models.
* @return CActiveDataProvider.
*/
public function getAll()
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria = new CDbCriteria();
$dp = new CActiveDataProvider(get_class($this), array('criteria' => $criteria, 'sort' => array('defaultOrder' => 'date ASC')));
$dp->setPagination(array('pageSize' => $dp->getTotalItemCount()));
return $dp;
}
示例13: getMyOtherTeams
/**
* Return list of all the members of other teams that this account belongs to.
* This is used for team that this account is NOT the master account of that team.
*
* @param unknown $account_id
*/
public function getMyOtherTeams($account_id, $subscription_id)
{
// get all master accounts that I'm member of
// $members = AccountTeamMember::model()->findAll('member_account_id = :account_id',
// array(":account_id" => $account_id));
// $master_accounts_ids = array(0);
// foreach($members as $mem)
// {
// $master_accounts_ids[] = $mem->master_account_id;
// }
// $master_accounts_ids_str = implode(',', $master_accounts_ids);
// get all members of these master accounts
$dataProvider = new CActiveDataProvider('AccountTeamMember', array('criteria' => array('condition' => "account_subscription_id = {$subscription_id} AND member_account_id = {$account_id}", 'order' => 'master_account_id DESC', 'with' => array('member_account'))));
$dataProvider->setPagination(false);
return $dataProvider;
}
示例14: actionIndex
/**
* Lists all models.
*/
public function actionIndex()
{
$criteria = new CDbCriteria(array('condition' => 'status=' . Post::STATUS_PUBLISHED, 'order' => 'update_time ASC', 'with' => array('commentCount', 'category')));
if (isset($_GET['tag'])) {
$criteria->addSearchCondition('tags', $_GET['tag']);
} elseif (isset($_GET['cat'])) {
$criteria->addCondition(array('category.url = :url'));
$criteria->params = array(':url' => $_GET['cat']);
} else {
$criteria->mergeWith(array('order' => 'update_time DESC', 'limit' => 7));
}
$dataProvider = new CActiveDataProvider('Post', array('pagination' => array('pageSize' => Yii::app()->params['postsPerPage'], 'pageVar' => "page"), 'criteria' => $criteria));
if (!isset($_GET['tag']) && !isset($_GET['cat'])) {
$dataProvider->setPagination(false);
}
$this->render('index', array('dataProvider' => $dataProvider));
}
示例15: loadAdvertisement
/**
* @return Advertisement[]
*/
protected function loadAdvertisement()
{
$dataProvider = new CActiveDataProvider('Advertisement', array('criteria' => array('order' => '`order` ASC, id ASC', 'offset' => $this->offset, 'limit' => $this->limit)));
$dataProvider->setPagination(false);
return $dataProvider->getData();
}