当前位置: 首页>>代码示例>>PHP>>正文


PHP CActiveDataProvider::setPagination方法代码示例

本文整理汇总了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;
 }
开发者ID:sam-it,项目名称:yii1-datatables,代码行数:49,代码来源:DataTable.php

示例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));
 }
开发者ID:adsavin,项目名称:air,代码行数:17,代码来源:DialogController.php

示例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));
 }
开发者ID:ekospinach,项目名称:berkuliah,代码行数:20,代码来源:HomeController.php

示例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,
        ));
    }
开发者ID:nico13051995,项目名称:IntITA,代码行数:40,代码来源:LessonController.php

示例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,
        ));
	}
开发者ID:nico13051995,项目名称:IntITA,代码行数:22,代码来源:PermissionsController.php

示例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
         }
     }
 }
开发者ID:xl602,项目名称:X2CRM,代码行数:59,代码来源:AdminController.php

示例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();
 }
开发者ID:nhuhtlb,项目名称:linxbooks,代码行数:23,代码来源:SystemList.php

示例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;
     }
 }
开发者ID:Lucerin,项目名称:Yii-projects,代码行数:22,代码来源:CLBActiveRecord.php

示例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));
 }
开发者ID:rapbore,项目名称:rch2,代码行数:11,代码来源:RecargaController.php

示例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;
 }
开发者ID:nhuhtlb,项目名称:linxbooks,代码行数:16,代码来源:AccountInvitation.php

示例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();
 }
开发者ID:nhuhtlb,项目名称:linxbooks,代码行数:6,代码来源:UserList.php

示例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;
 }
开发者ID:Cynabal,项目名称:postimer,代码行数:13,代码来源:Pos.php

示例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;
 }
开发者ID:Lucerin,项目名称:Yii-projects,代码行数:22,代码来源:AccountTeamMember.php

示例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));
 }
开发者ID:Romerohub,项目名称:Yii-blog,代码行数:20,代码来源:PageController.php

示例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();
 }
开发者ID:kosenka,项目名称:yboard,代码行数:9,代码来源:ShowAdvertisementWidget.php


注:本文中的CActiveDataProvider::setPagination方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。