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


PHP CQuery::from方法代码示例

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


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

示例1: getLoadPlanByType

 /**
  * Нагрузка по типу (лекция, практика, т.п.)
  * Параметрам
  *      type_1 - основная
  *      type_2 - дополнительная
  *      type_3 - надбавка
  *      type_4 - почасовка
  *      filials - с учетом выезда
  * Семестру
  *      1 - осенний
  *      2 - весенний
  * Типу данных
  *      0 - только бюджет
  *      1 - только контракт
  *      2 - сумма бюджета и контракта
  *
  * @param $typeAlias
  * @param array $params
  * @param int $period
  * @param int $dataType
  * @return int
  */
 private function getLoadPlanByType($typeAlias, $params = array(), $period = 1, $dataType = 2)
 {
     $result = 0;
     $defaulParams = array("type_1" => false, "type_2" => false, "type_3" => false, "type_4" => false, "filials" => false);
     $params = array_merge($defaulParams, $params);
     // общие условия
     $condition = array("kadri_id = " . $this->getLoad()->person_id, "year_id = " . $this->getLoad()->year->getId(), "part_id = " . $period);
     // типы нагрузки
     $types = array();
     if ($params["type_1"]) {
         $types[] = "1";
     }
     if ($params["type_2"]) {
         $types[] = "2";
     }
     if ($params["type_3"]) {
         $types[] = "3";
     }
     if ($params["type_4"]) {
         $types[] = "4";
     }
     if (count($types) > 0) {
         $condition[] = "hours_kind_type in (" . implode(", ", $types) . ")";
     } else {
         $condition[] = "hours_kind_type in (0)";
     }
     if ($params["filials"]) {
         $condition[] = "on_filial in (0, 1)";
     } else {
         $condition[] = "on_filial in (0)";
     }
     // какие столбцы брать и считать ли сумму
     $query = new CQuery();
     if ($dataType == 2) {
         $query->select("IFNULL(SUM(" . $typeAlias . "), 0) + IFNULL(SUM(" . $typeAlias . "_add), 0) as value");
     } elseif ($dataType == 1) {
         $query->select("IFNULL(SUM(" . $typeAlias . "_add), 0) as value");
     } elseif ($dataType == 0) {
         $query->select("IFNULL(SUM(" . $typeAlias . "), 0) as value");
     }
     $query->from(TABLE_IND_PLAN_PLANNED);
     $query->condition(implode(" AND ", $condition));
     $data = $query->execute()->getFirstItem();
     $result = $data["value"];
     return $result;
 }
开发者ID:Rustam44,项目名称:ASUPortalPHP,代码行数:68,代码来源:CIndPlanPersonLoadTable.class.php

示例2: getItemsCount

 /**
  * Количество записей в таблице
  *
  * @return int
  */
 public function getItemsCount()
 {
     if ($this->_manualAdded) {
         return $this->getCount();
     } else {
         $query = new CQuery();
         if (mb_strpos(mb_strtolower($this->getQuery()->getFields()), "distinct") === false) {
             $query->select("count(" . $this->getTableAlias() . ".id) as cnt");
         } else {
             $query->select("count(distinct " . $this->getTableAlias() . ".id) as cnt");
         }
         $query->from($this->getQuery()->getTable())->condition($this->getQuery()->getCondition());
         foreach ($this->getQuery()->getInnerJoins()->getItems() as $key => $value) {
             $query->innerJoin($key, $value);
         }
         foreach ($this->getQuery()->getLeftJoins() as $key => $value) {
             $query->leftJoin($key, $value);
         }
         $arr = $query->execute();
         if ($arr->getCount() > 0) {
             $item = $arr->getFirstItem();
             return $item["cnt"];
         } else {
             return 0;
         }
     }
 }
开发者ID:Rustam44,项目名称:ASUPortalPHP,代码行数:32,代码来源:CRecordSet.class.php


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