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


PHP CQuery::order方法代码示例

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


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

示例1: actionIndex

 public function actionIndex()
 {
     $set = new CRecordSet();
     $query = new CQuery();
     $query->select("year.*")->from(TABLE_YEARS . " as year")->order("year.name desc");
     if (CRequest::getString("order") == "year.date_start") {
         $direction = "asc";
         if (CRequest::getString("direction") != "") {
             $direction = CRequest::getString("direction");
         }
         $query->order("year.date_start " . $direction);
     }
     $years = new CArrayList();
     $set->setQuery($query);
     foreach ($set->getPaginated()->getItems() as $ar) {
         $year = new CTimeIntervals($ar);
         $years->add($year->getId(), $year);
     }
     $this->setData("paginator", $set->getPaginator());
     $this->setData("years", $years);
     $this->renderView("_time_intervals/index.tpl");
 }
开发者ID:Rustam44,项目名称:ASUPortalPHP,代码行数:22,代码来源:CTimeIntervalsController.class.php

示例2: getWithCondition

 /**
  * Лист записей из какой-либо таблицы по определенному условию
  *
  * @static
  * @param $table
  * @param $condition
  * @return CRecordSet
  */
 public static function getWithCondition($table, $condition, $order = null)
 {
     $key = $table . "_" . $condition . "_" . $order;
     if (!self::getCache()->hasElement($key)) {
         $set = new CRecordSet();
         $query = new CQuery();
         $query->select("*")->from($table)->condition($condition);
         if (!is_null($order)) {
             $query->order($order);
         }
         $set->setQuery($query);
         self::getCache()->add($key, $set);
     }
     return self::getCache()->getItem($key);
 }
开发者ID:Rustam44,项目名称:ASUPortalPHP,代码行数:23,代码来源:CActiveRecordProvider.class.php

示例3: actionIndex

 public function actionIndex()
 {
     $set = new CRecordSet(false);
     $query = new CQuery();
     $query->select("activity.*")->from(TABLE_STUDENTS_ACTIVITY . " as activity");
     // сортировки по столбцам
     if (CRequest::getString("order") == "") {
         $query->order("activity.id desc");
     } elseif (CRequest::getString("order") == "date_act") {
         if (CRequest::getString("direction") == "") {
             $query->order("activity.date_act desc");
         } else {
             $query->order("activity.id " . CRequest::getString("direction"));
         }
     } elseif (CRequest::getString("order") == "subject_id") {
         $query->leftJoin(TABLE_DISCIPLINES . " as discipline", "activity.subject_id = discipline.id");
         if (CRequest::getString("direction") == "") {
             $query->order("discipline.name asc");
         } else {
             $query->order("discipline.name " . CRequest::getString("direction"));
         }
     } elseif (CRequest::getString("order") == "kadri_id") {
         $query->leftJoin(TABLE_PERSON . " as person", "activity.kadri_id = person.id");
         if (CRequest::getString("direction") == "") {
             $query->order("person.fio asc");
         } else {
             $query->order("person.fio " . CRequest::getString("direction"));
         }
     } elseif (CRequest::getString("order") == "student_id") {
         $query->leftJoin(TABLE_STUDENTS . " as student_f", "student_f.id = activity.student_id");
         if (CRequest::getString("direction") == "") {
             $query->order("student_f.fio asc");
         } else {
             $query->order("student_f.fio " . CRequest::getString("direction"));
         }
     } else {
         $query = new CQuery();
         $query->select("activity.*")->from(TABLE_STUDENTS_ACTIVITY)->order("activity.id desc");
     }
     // запросы для получения списка групп и списка преподавателей
     $personQuery = new CQuery();
     $personQuery->select("distinct(person.id) as id, person.fio as name")->from(TABLE_STUDENTS_ACTIVITY . " as activity")->innerJoin(TABLE_PERSON . " as person", "activity.kadri_id = person.id")->order("person.fio asc");
     $groupQuery = new CQuery();
     $groupQuery->select("distinct(st_group.id) as id, st_group.name as name")->from(TABLE_STUDENTS_ACTIVITY . " as activity")->innerJoin(TABLE_STUDENTS . " as student", "student.id = activity.student_id")->innerJoin(TABLE_STUDENT_GROUPS . " as st_group", "st_group.id = student.group_id")->order("st_group.name asc");
     $disciplineQuery = new CQuery();
     $disciplineQuery->select("distinct(subject.id) as id, subject.name as name")->from(TABLE_STUDENTS_ACTIVITY . " as activity")->innerJoin(TABLE_DISCIPLINES . " as subject", "activity.subject_id = subject.id")->order("subject.name asc");
     // фильтры
     $selectedPerson = null;
     $selectedGroup = null;
     $selectedDiscipline = null;
     $selectedStudent = null;
     $selectedControl = null;
     if (CRequest::getString("filter") !== "") {
         $filters = explode("_", CRequest::getString("filter"));
         foreach ($filters as $filter) {
             $f = explode(":", $filter);
             if (count($f) > 1) {
                 $key = $f[0];
                 $value = $f[1];
                 if ($key == "person") {
                     if ($value != 0) {
                         $selectedPerson = $value;
                         $query->condition("kadri_id=" . $value);
                     }
                 } elseif ($key == "group") {
                     if ($value != 0) {
                         $selectedGroup = $value;
                         $query->innerJoin(TABLE_STUDENTS . " as student", "activity.student_id = student.id");
                         $query->innerJoin(TABLE_STUDENT_GROUPS . " as st_group", "student.group_id = st_group.id AND st_group.id=" . $value);
                     }
                 } elseif ($key == "discipline") {
                     if ($value != 0) {
                         $selectedDiscipline = $value;
                         $query->innerJoin(TABLE_DISCIPLINES . " as subject", "subject.id = activity.subject_id AND subject.id=" . $value);
                     }
                 } elseif ($key == "student") {
                     if ($value != 0) {
                         $selectedStudent = CStaffManager::getStudent($value);
                         $query->innerJoin(TABLE_STUDENTS . " as student", "activity.student_id = student.id AND student.id=" . $value);
                     }
                 } elseif ($key == "control") {
                     if ($value != 0) {
                         $selectedControl = CTaxonomyManager::getControlType($value);
                         $query->innerJoin(TABLE_STUDENTS_CONTROL_TYPES . " as control", "activity.study_act_id = control.id AND control.id=" . $value);
                     }
                 }
             }
         }
         /**
          * Дополняем фильтры по преподавателям, группам и дисциплинам
          */
         if (!is_null($selectedPerson)) {
             $groupQuery->innerJoin(TABLE_PERSON . " as person", "person.id = activity.kadri_id AND person.id=" . $selectedPerson);
             $disciplineQuery->innerJoin(TABLE_PERSON . " as person", "person.id = activity.kadri_id AND person.id=" . $selectedPerson);
         }
         if (!is_null($selectedGroup)) {
             $personQuery->innerJoin(TABLE_STUDENTS . " as student", "student.id = activity.student_id");
             $personQuery->innerJoin(TABLE_STUDENT_GROUPS . " as st_group", "st_group.id = student.group_id and st_group.id=" . $selectedGroup);
             $disciplineQuery->innerJoin(TABLE_STUDENTS . " as student", "student.id = activity.student_id");
             $disciplineQuery->innerJoin(TABLE_STUDENT_GROUPS . " as st_group", "st_group.id = student.group_id and st_group.id=" . $selectedGroup);
//.........这里部分代码省略.........
开发者ID:Trozeman,项目名称:ASUPortalPHP,代码行数:101,代码来源:CGradebookController.class.php


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