本文整理汇总了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;
}
示例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;
}
}
}