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


PHP Registration::sortDesc方法代码示例

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


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

示例1: search

 /**
  * Retrieves a list of models based on the current search/filter conditions.
  *
  * Typical usecase:
  * - Initialize the model fields with values from filter form.
  * - Execute this method to get CActiveDataProvider instance which will filter
  * models according to data in model fields.
  * - Pass data provider to CGridView, CListView or any similar widget.
  *
  * @return CActiveDataProvider the data provider that can return the models
  * based on the search/filter conditions.
  */
 public function search(&$columns = array())
 {
     // @todo Please modify the following code to remove attributes that should not be searched.
     $criteria = new CDbCriteria();
     $criteria->order = 't.date';
     $criteria->with = array('user', 'user.country', 'user.province', 'user.city', 'competition');
     $criteria->compare('t.id', $this->id, true);
     $criteria->compare('t.competition_id', $this->competition_id);
     $criteria->compare('t.user_id', $this->user_id);
     $criteria->compare('t.events', $this->events, true);
     $criteria->compare('t.comments', $this->comments, true);
     $criteria->compare('t.date', $this->date, true);
     $criteria->compare('t.status', $this->status);
     $criteria->compare('user.status', User::STATUS_NORMAL);
     $registrations = $this->findAll($criteria);
     $number = 1;
     $statistics = array();
     $statistics['number'] = 0;
     $statistics['new'] = 0;
     $statistics['paid'] = 0;
     $statistics['unpaid'] = 0;
     $statistics[User::GENDER_MALE] = 0;
     $statistics[User::GENDER_FEMALE] = 0;
     //detect sort attribute
     $sort = Yii::app()->controller->sGet('sort');
     $sort = explode('.', $sort);
     if (isset($sort[1]) && $sort[1] === 'desc') {
         self::$sortDesc = true;
     }
     $sort = $sort[0];
     if ($sort !== '') {
         switch ($sort) {
             case 'name':
             case 'gender':
             case 'country_id':
             case 'birthday':
             case 'email':
             case 'mobile':
                 self::$sortByUserAttribute = true;
             case 'number':
             case 'user_id':
             case 'location_id':
                 self::$sortAttribute = $sort;
                 break;
             default:
                 self::$sortByEvent = true;
                 self::$sortAttribute = $sort;
                 break;
         }
     }
     $wcaIds = array();
     foreach ($registrations as $registration) {
         if ($registration->isAccepted()) {
             $registration->number = $number++;
         }
         $statistics['number']++;
         $statistics[$registration->user->gender]++;
         if ($registration->user->wcaid === '') {
             $statistics['new']++;
         }
         foreach ($registration->events as $event) {
             if (!isset($statistics[$event])) {
                 $statistics[$event] = 0;
             }
             $statistics[$event]++;
         }
         $fee = $registration->getTotalFee();
         if ($registration->isPaid()) {
             $statistics['paid'] += $fee;
         } else {
             $statistics['unpaid'] += $fee;
         }
         //store wcaids
         if ($registration->user->wcaid) {
             $wcaIds[$registration->user->wcaid] = $registration;
         }
     }
     if (self::$sortByEvent === true && !empty($wcaIds)) {
         switch ($sort) {
             case '333bf':
             case '444bf':
             case '555bf':
             case '333mbf':
                 $modelName = 'RanksSingle';
                 break;
             default:
                 $modelName = 'RanksAverage';
                 break;
//.........这里部分代码省略.........
开发者ID:sunshy360,项目名称:cubingchina,代码行数:101,代码来源:Registration.php


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