當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。