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


PHP CActiveDataProvider::getTotalItemCount方法代码示例

本文整理汇总了PHP中CActiveDataProvider::getTotalItemCount方法的典型用法代码示例。如果您正苦于以下问题:PHP CActiveDataProvider::getTotalItemCount方法的具体用法?PHP CActiveDataProvider::getTotalItemCount怎么用?PHP CActiveDataProvider::getTotalItemCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CActiveDataProvider的用法示例。


在下文中一共展示了CActiveDataProvider::getTotalItemCount方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testCountCriteria

 public function testCountCriteria()
 {
     // 1
     $dataProvider = new CActiveDataProvider('Post', array('criteria' => array('condition' => 'content LIKE "%content%"', 'order' => 'create_time DESC', 'with' => array('author')), 'pagination' => array('pageSize' => 5)));
     $this->assertSame($dataProvider->countCriteria, $dataProvider->criteria);
     $this->assertEquals(5, $dataProvider->getTotalItemCount(true));
     // 2
     $dataProvider->setCountCriteria(array('condition' => 'content LIKE "%content 1%"'));
     $this->assertNotSame($dataProvider->countCriteria, $dataProvider->criteria);
     $this->assertEquals(1, $dataProvider->getTotalItemCount(true));
     // 3
     $dataProvider->setCountCriteria(array('condition' => 'content LIKE "%content%"'));
     $this->assertNotSame($dataProvider->countCriteria, $dataProvider->criteria);
     $this->assertEquals(5, $dataProvider->getTotalItemCount(true));
 }
开发者ID:super-d2,项目名称:codeigniter_demo,代码行数:15,代码来源:CActiveDataProviderTest.php

示例2: runAjax

 protected function runAjax()
 {
     /** @var \CClientScript; */
     $cs = Yii::app()->clientscript;
     $result = ['data' => $this->createDataArray()];
     $result['recordsTotal'] = intval($this->dataProvider->getTotalItemCount());
     $result['recordsFiltered'] = $this->filteredCount();
     $result['draw'] = Yii::app()->request->getParam('draw');
     if (isset($cs->scripts[$cs::POS_READY])) {
         $result['scripts'] = implode(" ", $cs->scripts[$cs::POS_READY]);
     }
     // Add filter values.
     $model = $this->dataProvider->model;
     $baseCriteria = $model->getDbCriteria();
     $result['filterData'] = [];
     /** @var \CDataColumn $column */
     foreach ($this->columns as $column) {
         if (isset($column->filter)) {
             switch ($column->filter) {
                 case "select":
                 case "select-strict":
                     $values = [];
                     // Get all values for this column.
                     $criteria = clone $this->dataProvider->countCriteria;
                     $criteria->distinct = true;
                     $criteria->select = $column->name;
                     foreach ($model->cache(120)->findAll($criteria) as $instance) {
                         $values[$instance->{$column->name}] = ["key" => $instance->{$column->name}, "value" => isset($column->value) ? $column->evaluateExpression($column->value, ['data' => $instance, 'row' => -1]) : $instance->{$column->name}];
                     }
                     usort($values, function ($a, $b) {
                         return strcasecmp($a['value'], $b['value']);
                     });
                     $result['filterData'][$column->name] = $values;
                     break;
                 case "select-month":
                     $values = [];
                     // Get all values for this column.
                     $criteria = clone $this->dataProvider->countCriteria;
                     $criteria->distinct = true;
                     $criteria->select = $column->name;
                     //                            $criteria->limit = -1;
                     //                              $command = App()->db->schema->commandBuilder->createFindCommand($model->tableName(), $criteria);
                     //                            $values = $command->queryColumn();
                     foreach ($model->findAll($criteria) as $dateModel) {
                         /** @var \DateTime $date */
                         $date = $dateModel->{$column->name};
                         $key = $date->format("Y-m");
                         $values[$key] = ["key" => $key, "value" => \Yii::app()->dateFormatter->format("MMMM yyyy", $date)];
                     }
                     krsort($values);
                     $result['filterData'][$column->name] = array_values($values);
                     break;
                 default:
             }
         }
     }
     $model->setDbCriteria($baseCriteria);
     header("Content-Type: application/json");
     echo json_encode($result, JSON_PRETTY_PRINT);
 }
开发者ID:sam-it,项目名称:yii1-datatables,代码行数:60,代码来源:DataTable.php

示例3: actionShowrecommended

 /**
  * 查看推荐记录
  */
 public function actionShowrecommended()
 {
     //echo time();die;
     //if ($_POST){var_dump($_POST);die;}
     //获取表单参数
     $CompanyName = Yii::app()->request->getParam("CompanyName");
     $MobPhone = Yii::app()->request->getParam("MobPhone");
     $Email = Yii::app()->request->getParam("Email");
     $Month = Yii::app()->request->getParam("Month");
     $RecomMethod = Yii::app()->request->getParam("RecomMethod");
     $MemberStatus = Yii::app()->request->getParam("MemberStatus");
     //设置页面标题
     $this->pageTitle = Yii::app()->name . ' - ' . "推荐记录";
     $organID = Yii::app()->user->getOrganID();
     //查询语句
     $sql = 't.RecomStatus=1 and t.OrganID= ' . $organID;
     if (!empty($CompanyName)) {
         //机构名称
         $sql .= " and t.CompanyName like '%" . $CompanyName . "%'";
     }
     if (!empty($MobPhone)) {
         //手机
         $sql .= " and t.MobPhone like '%" . $MobPhone . "%'";
     }
     if (!empty($Email)) {
         //邮箱
         $sql .= " and t.Email like '%" . $Email . "%'";
     }
     if (!empty($Month)) {
         //几月前
         $sql .= " and record.RecomTime>(UNIX_TIMESTAMP(NOW())-{$Month}*30*24*60*60)";
     }
     if (!empty($RecomMethod)) {
         //推荐方式
         $sql .= " and record.RecomMethod = '{$RecomMethod}'";
     }
     if (!empty($MemberStatus)) {
         //会员状态
         $sql .= " and record.MemberStatus = " . $MemberStatus;
     }
     $criteria = new CDbCriteria();
     $criteria->select = "*";
     $criteria->with = 'record';
     $criteria->condition = $sql;
     $dataProvider = new CActiveDataProvider('RecommendList', array('criteria' => $criteria, 'pagination' => array('pageSize' => '10')));
     $data = $dataProvider->getData();
     //无法传值到表单中    暂时用PayStatus字段保存收益
     foreach ($data as $key => $value) {
         if ($value['CompanyType'] == 1) {
             $value['CompanyType'] = '生产商';
         } elseif ($value['CompanyType'] == 2) {
             $value['CompanyType'] = '经销商';
         } else {
             $value['CompanyType'] = '服务店';
         }
     }
     $count = $dataProvider->getTotalItemCount();
     //count($recmlistes);
     $this->render('showrecommended', array('dataProvider' => $dataProvider, 'count' => $count));
 }
开发者ID:zwq,项目名称:unpei,代码行数:63,代码来源:PartnerController.php

示例4: page

 /**
  * 手机客户端的分页,防止分页重复,与网页显示无关
  * @param  CActiveDataProvider $dataProvider
  *
  */
 public function page(CActiveDataProvider &$dataProvider, $more = true)
 {
     $total = $dataProvider->getTotalItemCount();
     $pageSzie = $dataProvider->getPagination()->getPageSize();
     $dataProvider->getPagination()->pageVar = 'page';
     $pageCount = ceil($total / $pageSzie);
     if ($dataProvider->getTotalItemCount() == 0) {
         $this->send(ERROR_EMPTY, 'data empty', $more);
     } else {
         if (isset($_GET['page'])) {
             if ($pageCount >= $_GET['page']) {
                 $this->send(0, $dataProvider->getData(), $more, array('page' => $pageCount));
             }
         } else {
             $this->send(ERROR_NONE, $dataProvider->getData(), $more, array('page' => $pageCount));
         }
     }
 }
开发者ID:tiger2soft,项目名称:travelman,代码行数:23,代码来源:Controller.php

示例5: actionBrowse

 /**
  * Renders the browse view and caluclates required values for the
  * roller (image roll at the page top).
  */
 public function actionBrowse()
 {
     // the browse view requires information on the basket contents
     $testBasket = Yii::app()->user->getState('basketContents');
     if (!isset($testBasket)) {
         Yii::app()->user->setState('basketContents', array());
     }
     // the user can't access ?r=image/browse without the offset value set
     if (!isset($_GET['browseOffset'])) {
         $this->redirect(array('search'));
     }
     $currentlyviewedrow = $_GET['browseOffset'];
     // if someone tries to manually enter an invalid number, negative, it's set to 0
     if ($currentlyviewedrow < 0) {
         $currentlyviewedrow = 0;
     }
     // next and prev variables set.
     $next = $currentlyviewedrow + 1;
     $prev = $currentlyviewedrow - 1;
     $rollCriteria = Yii::app()->user->getState('imagesearchcriteria');
     $rollCriteria->offset = $currentlyviewedrow - 4;
     if ($currentlyviewedrow < 5) {
         $rollCriteria->limit = $currentlyviewedrow + 5;
     } else {
         $rollCriteria->limit = 9;
     }
     $rollDataProvider = new CActiveDataProvider('Image', array('criteria' => $rollCriteria, 'Pagination' => false));
     $totalAmount = $rollDataProvider->getTotalItemCount();
     $this->render('browse', array('rollDataProvider' => $rollDataProvider, 'browseOffset' => $currentlyviewedrow, 'next' => $next, 'prev' => $prev, 'totalAmount' => $totalAmount));
 }
开发者ID:kasdf9001,项目名称:yii-image-archive,代码行数:34,代码来源:ImageController.php

示例6: getVcrLinks

 /**
  * Generates an array of links for the VCR controls based on the specified dataprovider and 
  * current ID
  * @param CActiveDataProvider $dataProvider the data provider of the most recent gridview
  * @param Integer $id the ID of the current record
  * @return Array array of VCR links and stats
  */
 public static function getVcrLinks(&$dataProvider, $modelId)
 {
     $criteria = $dataProvider->criteria;
     $tableSchema = X2Model::model($dataProvider->modelClass)->getTableSchema();
     if ($tableSchema === null) {
         return false;
     }
     // for the first query, find the current ID's row number in the list
     $criteria->select = 't.id';
     // we also need any columns that are being used in the sort
     foreach (explode(',', $criteria->order) as $token) {
         // so loop through $criteria->order and extract them
         $token = preg_replace('/\\s|asc|desc/i', '', $token);
         if ($token !== '' && $token !== 'id' && $token != 't.id') {
             if (strpos($token, '.') != 1) {
                 $criteria->select .= ',t.' . $token;
             } else {
                 $criteria->select .= ',' . $token;
             }
         }
     }
     // always include "id DESC" in sorting (for order consistency with SmartDataProvider)
     if (!preg_match('/\\bid\\b/', $criteria->order)) {
         if (!empty($criteria->order)) {
             $criteria->order .= ',';
         }
         $criteria->order .= 't.id DESC';
     }
     // get search conditions (WHERE, JOIN, ORDER BY, etc) from the criteria
     $searchConditions = Yii::app()->db->getCommandBuilder()->createFindCommand($tableSchema, $criteria)->getText();
     /*
      * VCR Button Row Number Selection Query
      * 
      * This complicated block of code defines where a record is in the row
      * set to determine its position for VCR controls. This relies on SQL
      * variables and incrementing the variable in each row of the result set
      * from the subquery. A version of this query in plain MySQL looks like:
      * SELECT r-1 
      *   FROM (
      *       SELECT *,@rownum:=@rownum + 1 AS r 
      *       FROM ('.$searchConditions.') t1, (SELECT @rownum:=0) r) t2 
      *   WHERE t2.id='.$modelId
      */
     $varPrefix = '@';
     //Current prefix is MySQL specific
     $varName = $varPrefix . 'rownum';
     $varText = 'SET ' . $varName . ' = 0';
     // Current declaration is MySQL specific
     Yii::app()->db->createCommand()->setText($varText)->execute();
     $subQuery = Yii::app()->db->createCommand()->select('*, (' . $varName . ':=' . $varName . '+1) r')->from('(' . $searchConditions . ') t1')->getText();
     $rowNumberQuery = Yii::app()->db->createCommand()->select('(r-1)')->from('(' . $subQuery . ') t2')->where('t2.id=:t2_id');
     //        $rowNumberQuery = Yii::app()->db->createCommand('
     //            SELECT r-1
     //            FROM (
     //                SELECT *,@rownum:=@rownum + 1 AS r
     //                FROM ('.$searchConditions.') t1, (SELECT @rownum:=0) r) t2
     //            WHERE t2.id='.$modelId
     //        );
     // attach params from $criteria to this query
     $rowNumberQuery->params = array_merge(array(':t2_id' => $modelId), $criteria->params);
     $rowNumber = $rowNumberQuery->queryScalar();
     if ($rowNumber === false) {
         // the specified record isn't in this list
         return false;
     } else {
         $criteria->select = '*';
         // need to select everything to be sure ORDER BY will work
         if ($rowNumber == 0) {
             // if we're on the first row, get 2 items, otherwise get 3
             $criteria->offset = 0;
             $criteria->limit = 2;
             $vcrIndex = 0;
         } else {
             $criteria->offset = $rowNumber - 1;
             $criteria->limit = 3;
             $vcrIndex = 1;
             // index of current record in $vcrModels
         }
         $vcrModels = Yii::app()->db->getCommandBuilder()->createFindCommand($tableSchema, $criteria)->queryAll();
         $count = $dataProvider->getTotalItemCount();
         $vcrData = array();
         $vcrData['index'] = $rowNumber + 1;
         $vcrData['count'] = $dataProvider->getTotalItemCount();
         /* if($vcrIndex > 0)		// there's a record before the current one
                       $vcrData['prev'] = '<li class="prev">'.CHtml::link('<',array('view/'.$vcrModels[0]['id']),array('title'=>$vcrModels[0]['name'],'class'=>'x2-button')).'</li>';
                       else
                       $vcrData['prev'] = '<li class="prev">'.CHtml::link('<','javascript:void(0);',array('class'=>'x2-button disabled')).'</li>';
         
                       if(count($vcrModels) - 1 > $vcrIndex)	// there's a record after the current one
                       $vcrData['next'] = '<li class="next">'.CHtml::link('>', array('view/'.$vcrModels[$vcrIndex+1]['id']), array('title'=>$vcrModels[$vcrIndex+1]['name'],'class'=>'x2-button')).'</li>';
                       else
                       $vcrData['next'] = '<li class="next">'.CHtml::link('>','javascript:void(0);',array('class'=>'x2-button disabled')).'</li>';
                      */
//.........这里部分代码省略.........
开发者ID:xl602,项目名称:X2CRM,代码行数:101,代码来源:X2List.php

示例7: getTotalItemCount

 /**
  * Returns the total number of data items.
  * When {@link pagination} is set false, this returns the same value as {@link itemCount}.
  * @param boolean $refresh whether the total number of data items should be re-calculated.
  * @return integer total number of possible data items.
  */
 public function getTotalItemCount($refresh = false)
 {
     /* x2modstart */
     if ($this->calculateChecksum && $refresh) {
         throw new CException('refresh cannot be called if calculcateChecksum is set to true');
     }
     /* x2modend */
     return parent::getTotalItemCount($refresh);
 }
开发者ID:keyeMyria,项目名称:CRM,代码行数:15,代码来源:SmartActiveDataProvider.php

示例8: ceil

                break;
            case 1:
                echo '筹资成功';
                break;
            case 2:
                echo '筹资失败';
                break;
            default:
                echo '筹资中';
        }
        ?>
                            </td>
                        </tr>
                        <?php 
    }
    $totalpages = ceil($dataProvider->getTotalItemCount() / 20);
    ?>
                    <tr><td colspan=9>
                            <div class="text-center">
                                <ul id="pagination-memerlog" class="pagination-sm"></ul>
                            </div>
                        </td>
                <script type="text/javascript">
                    $('#pagination-memerlog').twbsPagination({
                        totalPages: <?php 
    echo $totalpages;
    ?>
,
                        visiblePages: <?php 
    echo $totalpages >= 5 ? 5 : $totalpages;
    ?>
开发者ID:bfyang5130,项目名称:zzl,代码行数:31,代码来源:tfail.php

示例9: 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

示例10: actionJqgriddata

 public function actionJqgriddata()
 {
     $rowsCount = $_GET['rows'] == 0 ? 10 : $_GET['rows'];
     $page = $_GET['page'] == 0 ? 1 : $_GET['page'];
     $dataProvider = new CActiveDataProvider('WotPlayer', array('pagination' => array('pageSize' => $rowsCount, 'currentPage' => $page - 1)));
     $responce->page = $page;
     $responce->records = $dataProvider->getTotalItemCount();
     $responce->total = ceil($responce->records / $rowsCount);
     $rows = $dataProvider->getData();
     foreach ($rows as $i => $row) {
         $responce->rows[$i]['id'] = $row->getPrimaryKey();
         $responce->rows[$i]['cell'] = array($row->player_id, $row->player_name);
     }
     echo json_encode($responce);
 }
开发者ID:joelsantosjunior,项目名称:wotdb,代码行数:15,代码来源:WotController.php

示例11: search

 /**
  * Retrieves a list of models based on the current search/filter conditions.
  * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
  */
 public function search()
 {
     // Warning: Please modify the following code to remove attributes that
     // should not be searched.
     $criteria = new CDbCriteria();
     $criteria->together = true;
     $criteria->with = array('usuario');
     $criteria->compare('itens_id', $this->itens_id);
     $criteria->compare('itens_titulo', $this->itens_titulo, true);
     $criteria->compare('itens_descricao', $this->itens_descricao, true);
     $criteria->compare('itens_excluido', $this->itens_excluido);
     $criteria->compare('itens_dt_criacao', $this->itens_dt_criacao, true);
     $criteria->compare('itens_dt_modificacao', $this->itens_dt_modificacao, true);
     $criteria->compare('itens_destaque', $this->itens_destaque, true);
     $criteria->compare('itens_atividade', $this->itens_atividade);
     $criteria->compare('itens_cnae', $this->itens_cnae);
     $criteria->compare('itens_uf', $this->itens_uf, true);
     $criteria->compare('itens_cidade', $this->itens_cidade, true);
     //$criteria->compare('itens_preco',$this->itens_preco,true);
     //$criteria->compare('itens_receita_anual',$this->itens_receita_anual,true);
     //$criteria->compare('itens_ebitda',$this->itens_ebitda,true);
     //$criteria->compare('itens_resultado_operacional',$this->itens_resultado_operacional,true);
     $criteria->compare('itens_fluxo_de_caixa', $this->itens_fluxo_de_caixa, true);
     $criteria->compare('itens_destaque_detalhes', $this->itens_destaque_detalhes, true);
     $criteria->compare('itens_localizacao', $this->itens_localizacao, true);
     $criteria->compare('itens_fundacao', $this->itens_fundacao, true);
     $criteria->compare('itens_tipo', $this->itens_tipo, true);
     $criteria->compare('itens_funcionarios', $this->itens_funcionarios, true);
     $criteria->compare('itens_area_total', $this->itens_area_total, true);
     $criteria->compare('itens_area_total_locavel', $this->itens_area_total_locavel, true);
     $criteria->compare('itens_unidades', $this->itens_unidades, true);
     $criteria->compare('itens_incluso_na_venda', $this->itens_incluso_na_venda, true);
     $criteria->compare('itens_curiosidades', $this->itens_curiosidades, true);
     $criteria->compare('itens_financas', $this->itens_financas, true);
     $criteria->compare('itens_receita_total', $this->itens_receita_total, true);
     $tipo_usuario = Yii::app()->user->getState(Yii::app()->params['user_session_usuario_tipo']);
     $tipo_usuario = $tipo_usuario[Yii::app()->params['user_session_usuario_tipo']];
     $id_usuario = Yii::app()->user->getState(Yii::app()->params['user_session_usuario_id']);
     $id_usuario = $id_usuario[Yii::app()->params['user_session_usuario_id']];
     /* se for meus negócios */
     if (Yii::app()->controller->id == 'meusnegocios') {
         $criteria->compare('usuario.usuario_id', $id_usuario);
     } else {
         $criteria->compare('usuario_id', $this->usuario_id);
     }
     $this->pg_size = Yii::app()->params['listPerPage'];
     /* se vier do front página negócios a venda */
     if (Yii::app()->controller->id == 'negociosavenda') {
         $criteria->compare('itens_excluido', 'S');
         /* Por default carrega somente os destaques */
         if (!isset($_GET['buscar']) && !isset($_POST['buscar'])) {
             $criteria->compare('itens_destaque', 'S');
             $this->pg_size = Yii::app()->params['listPerPageDestaque'];
             //$criteria->order=new CDbExpression('RAND()');
         }
         $this->compararPrecos($criteria);
     }
     //$criteria->addBetweenCondition('itens_receita_anual', 200, 400, 'AND');
     $sort = new CSort();
     $sort->defaultOrder = !isset($_GET['buscar']) && !isset($_POST['buscar']) && Yii::app()->controller->id != 'meusnegocios' && Yii::app()->controller->id != 'negocios' ? 'RANDOM()' : array('itens_id' => true);
     /* retorna o total de registros */
     $mActive = new CActiveDataProvider($this, array('criteria' => $criteria, 'sort' => $sort));
     $this->totReg = !isset($_GET['buscar']) && !isset($_POST['buscar']) && Yii::app()->controller->id != 'meusnegocios' && Yii::app()->controller->id != 'negocios' ? $this->pg_size : $mActive->getTotalItemCount();
     return new CActiveDataProvider($this, array('criteria' => $criteria, 'sort' => $sort, 'pagination' => array('pageSize' => $this->pg_size), 'totalItemCount' => $this->totReg));
 }
开发者ID:renatocosta,项目名称:sunbeltbrasil,代码行数:69,代码来源:Itens.php

示例12: actionIndex

    /**
     * This is the default 'index' action that is invoked
     * when an action is not explicitly requested by users.
     */
    public function actionIndex($selector = 'all')
    {
        // renders the view file 'protected/views/site/index.php'
        // using the default layout 'protected/views/layouts/main.php'

        $criteria= new CDbCriteria;
        $criteria->alias = 'course';
        $criteria->order = 'rating DESC';
        if ($selector !== 'all'){
            if ($selector == 'junior'){
                $criteria->addInCondition('level', array('intern','strong junior','junior'));
            } else {
                $criteria->condition = 'level=:level';
                $criteria->params = array(':level'=>$selector);
            }
        }

        $dataProvider = new CActiveDataProvider('Course', array(
            'criteria' => $criteria,
            'Pagination'=>false,
        ));

        $total = $dataProvider->getTotalItemCount();
        $count1 =round($total/2);
        $count2 = $total - $count1;

        $this->render('index', array(

            'dataProvider' => $dataProvider,
            'count1' => $count1,
            'count2' => $count2,
        ));
    }
开发者ID:nico13051995,项目名称:IntITA,代码行数:37,代码来源:CoursesController.php


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