本文整理汇总了PHP中CQuery::condition方法的典型用法代码示例。如果您正苦于以下问题:PHP CQuery::condition方法的具体用法?PHP CQuery::condition怎么用?PHP CQuery::condition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CQuery
的用法示例。
在下文中一共展示了CQuery::condition方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionSearch
public function actionSearch()
{
$res = array();
$term = CRequest::getString("query");
/**
* Сначала поищем по названию группы
*/
$query = new CQuery();
$query->select("distinct(page.id) as id, page.title as name")->from(TABLE_PAGES . " as page")->condition("page.title like '%" . $term . "%'")->limit(0, 5);
if (CSession::getCurrentUser()->getLevelForCurrentTask() == ACCESS_LEVEL_READ_OWN_ONLY or CSession::getCurrentUser()->getLevelForCurrentTask() == ACCESS_LEVEL_WRITE_OWN_ONLY) {
$query->condition("page.title like '%" . $term . "%' AND page.user_id_insert = " . CSession::getCurrentUser()->getId());
}
foreach ($query->execute()->getItems() as $item) {
$res[] = array("field" => "id", "value" => $item["id"], "label" => $item["name"], "class" => "CPage");
}
echo json_encode($res);
}
示例2: actionIndex
public function actionIndex()
{
$set = new CRecordSet();
$query = new CQuery();
$query->select("news.*")->from(TABLE_NEWS . " as news")->order("news.id desc");
if (CSession::getCurrentUser()->getStatus() !== USER_TYPE_ADMIN) {
$query->condition("news.user_id_insert = " . CSession::getCurrentUser()->getId());
}
$set->setQuery($query);
$news = new CArrayList();
foreach ($set->getPaginated()->getItems() as $ar) {
$newsItem = new CNewsItem($ar);
$news->add($newsItem->getId(), $newsItem);
}
$this->setData("paginator", $set->getPaginator());
$this->setData("news", $news);
$this->renderView("_news/index.tpl");
}
示例3: actionIndex
public function actionIndex()
{
$set = new CRecordSet();
$query = new CQuery();
$query->select("gr.*")->from(TABLE_GRANTS . " as gr")->order("gr.id desc");
if (CSession::getCurrentUser()->getLevelForCurrentTask() == ACCESS_LEVEL_READ_OWN_ONLY || CSession::getCurrentUser()->getLevelForCurrentTask() == ACCESS_LEVEL_WRITE_OWN_ONLY) {
$query->leftJoin(TABLE_GRANT_MEMBERS . " as m", "m.grant_id = gr.id");
$query->condition("gr.author_id=" . CSession::getCurrentPerson()->getId() . " OR m.person_id=" . CSession::getCurrentPerson()->getId() . " or gr.manager_id=" . CSession::getCurrentUser()->getId());
}
$set->setQuery($query);
$grants = new CArrayList();
foreach ($set->getPaginated()->getItems() as $ar) {
$grant = new CGrant($ar);
$grants->add($grant->getId(), $grant);
}
$this->setData("grants", $grants);
$this->setData("paginator", $set->getPaginator());
$this->renderView("_grants/grant/index.tpl");
}
示例4: 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;
}
示例5: 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);
//.........这里部分代码省略.........
示例6: actionStatistic
public function actionStatistic()
{
$set = new CRecordSet();
$query = new CQuery();
$query->select("preview.*")->from(TABLE_DIPLOM_PREVIEWS . " as preview")->order("preview.date_preview desc");
$set->setQuery($query);
$isArchive = CRequest::getString("isArchive") == "1";
if (!$isArchive) {
$query->condition('preview.date_preview between "' . date("Y-m-d", strtotime(CUtils::getCurrentYear()->date_start)) . '" and "' . date("Y-m-d", strtotime(CUtils::getCurrentYear()->date_end)) . '"');
}
$this->addActionsMenuItem(array("title" => "Назад", "link" => "?action=index", "icon" => "actions/edit-undo.png"));
if ($isArchive) {
$requestParams = array();
foreach (CRequest::getGlobalRequestVariables()->getItems() as $key => $value) {
if ($key != "isArchive") {
$requestParams[] = $key . "=" . $value;
}
}
$this->addActionsMenuItem(array(array("title" => "Текущий год", "link" => "?" . implode("&", $requestParams), "icon" => "mimetypes/x-office-calendar.png")));
} else {
$requestParams = array();
foreach (CRequest::getGlobalRequestVariables()->getItems() as $key => $value) {
$requestParams[] = $key . "=" . $value;
}
$requestParams[] = "isArchive=1";
$this->addActionsMenuItem(array(array("title" => "Архив", "link" => "?" . implode("&", $requestParams), "icon" => "devices/media-floppy.png")));
}
$prevs = array();
foreach ($query->execute()->getItems() as $ar) {
$prev = new CDiplomPreview(new CActiveRecord($ar));
$prevs[$prev->getId()] = $prev->date_preview;
}
$date_previews = array();
$date_previews = array_count_values($prevs);
//Общее количество предзащит
$count_previews = count($prevs);
//Общее количество защит
$queryAll = new CQuery();
$queryAll->select("diplom.*")->from(TABLE_DIPLOMS . " as diplom");
if (!$isArchive) {
$queryAll->condition('diplom.date_act between "' . date("Y-m-d", strtotime(CUtils::getCurrentYear()->date_start)) . '" and "' . date("Y-m-d", strtotime(CUtils::getCurrentYear()->date_end)) . '"');
}
$count_all = $queryAll->execute()->getCount();
//Всего защит зимой
$queryWinterAll = new CQuery();
$queryWinterAll->select("diplom.*")->from(TABLE_DIPLOMS . " as diplom")->condition('diplom.date_act between "' . (date("Y") - 1) . "-12-01" . '" and "' . date("Y") . "-02-28" . '"');
$count_winter_all = $queryWinterAll->execute()->getCount();
//Всего защит летом
$querySummerAll = new CQuery();
$querySummerAll->select("diplom.*")->from(TABLE_DIPLOMS . " as diplom")->condition('diplom.date_act between "' . date("Y") . "-05-01" . '" and "' . date("Y") . "-06-30" . '"');
$count_summer_all = $querySummerAll->execute()->getCount();
//Из них не имеющие предзащиты зимой
$queryNotPreviewsWinter = new CQuery();
$queryNotPreviewsWinter->select("diplom.*")->from(TABLE_DIPLOMS . " as diplom")->leftJoin(TABLE_DIPLOM_PREVIEWS . " as preview", "diplom.student_id = preview.student_id")->condition('preview.student_id is null and diplom.date_act between "' . (date("Y") - 1) . "-12-01" . '" and "' . date("Y") . "-02-28" . '"');
$count_not_previews_winter = $queryNotPreviewsWinter->execute()->getCount();
//Из них не имеющие предзащиты летом
$queryNotPreviewsSummer = new CQuery();
$queryNotPreviewsSummer->select("diplom.*")->from(TABLE_DIPLOMS . " as diplom")->leftJoin(TABLE_DIPLOM_PREVIEWS . " as preview", "diplom.student_id = preview.student_id")->condition('preview.student_id is null and diplom.date_act between "' . date("Y") . "-05-01" . '" and "' . date("Y") . "-06-30" . '"');
$count_not_previews_summer = $queryNotPreviewsSummer->execute()->getCount();
//Количество предзащит зимой
$queryWinter = new CQuery();
$queryWinter->select("preview.*")->from(TABLE_DIPLOM_PREVIEWS . " as preview")->condition('preview.date_preview between "' . (date("Y") - 1) . "-12-01" . '" and "' . date("Y") . "-02-28" . '"');
$count_previews_winter = $queryWinter->execute()->getCount();
//Количество предзащит летом
$querySummer = new CQuery();
$querySummer->select("preview.*")->from(TABLE_DIPLOM_PREVIEWS . " as preview")->condition('preview.date_preview between "' . date("Y") . "-05-01" . '" and "' . date("Y") . "-06-30" . '"');
$count_previews_summer = $querySummer->execute()->getCount();
//Прошедшие предзащиту зимой
$queryWinterComplete = new CQuery();
$queryWinterComplete->select("preview.*")->from(TABLE_DIPLOM_PREVIEWS . " as preview")->condition('preview.date_preview between "' . (date("Y") - 1) . "-12-01" . '" and "' . date("Y") . "-02-28" . '" and (preview.diplom_percent!=0 and preview.another_view=0)');
$count_previews_winter_complete = $queryWinterComplete->execute()->getCount();
//Прошедшие предзащиту летом
$querySummerComplete = new CQuery();
$querySummerComplete->select("preview.*")->from(TABLE_DIPLOM_PREVIEWS . " as preview")->condition('preview.date_preview between "' . date("Y") . "-05-01" . '" and "' . date("Y") . "-06-30" . '" and (preview.diplom_percent!=0 and preview.another_view=0)');
$count_previews_summer_complete = $querySummerComplete->execute()->getCount();
//Не прошедшие предзащиту зимой
$queryWinterNotComplete = new CQuery();
$queryWinterNotComplete->select("preview.*")->from(TABLE_DIPLOM_PREVIEWS . " as preview")->condition('preview.date_preview between "' . (date("Y") - 1) . "-12-01" . '" and "' . date("Y") . "-02-28" . '" and (preview.diplom_percent=0 or preview.another_view!=0)');
$count_previews_winter_not_complete = $queryWinterNotComplete->execute()->getCount();
//Не прошедшие предзащиту летом
$querySummerNotComplete = new CQuery();
$querySummerNotComplete->select("preview.*")->from(TABLE_DIPLOM_PREVIEWS . " as preview")->condition('preview.date_preview between "' . date("Y") . "-05-01" . '" and "' . date("Y") . "-06-30" . '" and (preview.diplom_percent=0 or preview.another_view!=0)');
$count_previews_summer_not_complete = $querySummerNotComplete->execute()->getCount();
$this->setData("date_previews", $date_previews);
$this->setData("count_all", $count_all);
$this->setData("count_previews", $count_previews);
$this->setData("count_winter_all", $count_winter_all);
$this->setData("count_summer_all", $count_summer_all);
$this->setData("count_not_previews_winter", $count_not_previews_winter);
$this->setData("count_not_previews_summer", $count_not_previews_summer);
$this->setData("count_previews_winter", $count_previews_winter);
$this->setData("count_previews_summer", $count_previews_summer);
$this->setData("count_previews_winter_complete", $count_previews_winter_complete);
$this->setData("count_previews_winter_not_complete", $count_previews_winter_not_complete);
$this->setData("count_previews_summer_complete", $count_previews_summer_complete);
$this->setData("count_previews_summer_not_complete", $count_previews_summer_not_complete);
$this->renderView("_diploms/diplom_preview/stat.tpl");
}
示例7: actionSearch
public function actionSearch()
{
$res = array();
$term = CRequest::getString("query");
/**
* Сначала поищем по названию публикации
*/
$query = new CQuery();
$query->select("distinct(pub.id) as id, pub.name as title")->from(TABLE_PUBLICATIONS . " as pub")->condition("pub.name like '%" . $term . "%'")->limit(0, 5);
if (CSession::getCurrentUser()->getLevelForCurrentTask() == ACCESS_LEVEL_READ_OWN_ONLY or CSession::getCurrentUser()->getLevelForCurrentTask() == ACCESS_LEVEL_WRITE_OWN_ONLY) {
$query->innerJoin(TABLE_PUBLICATION_BY_PERSONS . " as p", "p.izdan_id = pub.id");
$query->condition("p.kadri_id=" . CSession::getCurrentPerson()->getId());
}
foreach ($query->execute()->getItems() as $item) {
$res[] = array("field" => "t.id", "value" => $item["id"], "label" => $item["title"], "class" => "CPublication");
}
echo json_encode($res);
}
示例8: actionExport
public function actionExport()
{
/**
* Выбираем данные. Если ничего не получено, то
* экспортируем все описатели
*/
$selected = CRequest::getArray("selected");
$query = new CQuery();
$query->select("id")->from(TABLE_PRINT_FIELDS);
if (count($selected) > 0) {
$query->condition("id in (" . implode(", ", $selected) . ")");
}
$fields = array();
foreach ($query->execute()->getItems() as $item) {
$field = CPrintManager::getField($item["id"]);
$field_arr = array("alias" => $field->alias, "title" => $field->title, "description" => $field->description, "value_evaluate" => $field->value_evaluate, "parent_node" => $field->parent_node);
/**
* Данные о родителе и связанных вставляем как алиасы
*/
if (!is_null($field->parent)) {
$field_arr["parent"] = $field->parent->alias;
}
/**
* Данные о наборе форм так же
*/
if (!is_null($field->formset)) {
$field_arr["formset"] = $field->formset->alias;
}
$fields[] = $field_arr;
}
echo serialize($fields);
}
示例9: actionIndex
public function actionIndex()
{
if (CSettingsManager::getSettingValue("hide_person_data_rule")) {
$set = new CRecordSet();
$query = new CQuery();
$query->select("users.*")->from(TABLE_USERS . " as users")->innerJoin(TABLE_USER_IN_GROUPS . " as userGroup", "userGroup.user_id=users.id")->condition("userGroup.group_id=1")->order("users.FIO asc");
$queryLetter = new CQuery();
$queryLetter->select("users.*, UPPER(left(users.FIO,1)) as name, count(*) as cnt")->from(TABLE_USERS . " as users")->innerJoin(TABLE_USER_IN_GROUPS . " as userGroup", "userGroup.user_id=users.id")->condition("userGroup.group_id=1 ")->group(1)->order("users.FIO asc");
$resRus = array();
foreach ($queryLetter->execute()->getItems() as $ar) {
$res = new CLecturerOuter(new CActiveRecord($ar));
$resRus[$res->id] = $res->name;
}
$resRusLetters = array();
$resRusLetters = array_count_values($resRus);
$firstLet = array(1);
foreach ($resRusLetters as $key => $value) {
$firstLet[] = $key;
}
$letter = $firstLet[CRequest::getInt("getsub")];
$letterId = -1;
if (CRequest::getInt("getsub") > 0 and is_null(CRequest::getFilter("user.id"))) {
if (CRequest::getInt("getsub") > 0) {
$letterId = CRequest::getInt("getsub");
}
$query->condition('users.FIO like "' . $letter . '%" and userGroup.group_id=1');
}
$lects = new CArrayList();
$set->setQuery($query);
foreach ($set->getPaginated()->getItems() as $ar) {
$lect = new CLecturerOuter($ar);
$lects->add($lect->getId(), $lect);
}
} else {
$set = new CRecordSet();
$query = new CQuery();
$query->select("person.*")->from(TABLE_PERSON . " as person")->innerJoin(TABLE_USERS . " as users", "users.kadri_id=person.id")->innerJoin(TABLE_USER_IN_GROUPS . " as userGroup", "userGroup.user_id=users.id")->condition("userGroup.group_id=1")->order("person.fio asc");
$queryLetter = new CQuery();
$queryLetter->select("person.*, UPPER(left(person.fio,1)) as name, count(*) as cnt")->from(TABLE_PERSON . " as person")->innerJoin(TABLE_USERS . " as users", "users.kadri_id=person.id")->innerJoin(TABLE_USER_IN_GROUPS . " as userGroup", "userGroup.user_id=users.id")->condition("userGroup.group_id=1 ")->group(1)->order("person.fio asc");
$resRus = array();
foreach ($queryLetter->execute()->getItems() as $ar) {
$res = new CPerson(new CActiveRecord($ar));
$resRus[$res->id] = $res->name;
}
$resRusLetters = array();
$resRusLetters = array_count_values($resRus);
$firstLet = array(1);
foreach ($resRusLetters as $key => $value) {
$firstLet[] = $key;
}
$letter = $firstLet[CRequest::getInt("getsub")];
$letterId = -1;
if (CRequest::getInt("getsub") > 0 and is_null(CRequest::getFilter("person.id"))) {
if (CRequest::getInt("getsub") > 0) {
$letterId = CRequest::getInt("getsub");
}
$query->condition('person.fio like "' . $letter . '%" and userGroup.group_id=1');
}
if (CSession::isAuth() and (CSession::getCurrentUser()->getLevelForCurrentTask() == ACCESS_LEVEL_WRITE_OWN_ONLY or CSession::getCurrentUser()->getLevelForCurrentTask() == ACCESS_LEVEL_WRITE_ALL)) {
$this->addActionsMenuItem(array(array("title" => "Добавить биографию", "link" => WEB_ROOT . "_modules/_biography/index.php", "icon" => "actions/list-add.png")));
}
$lects = new CArrayList();
$set->setQuery($query);
foreach ($set->getPaginated()->getItems() as $ar) {
$lect = new CPerson($ar);
$lects->add($lect->getId(), $lect);
}
}
$this->setData("resRusLetters", $resRusLetters);
$this->setData("letterId", $letterId);
$this->setData("firstLet", $firstLet);
$this->setData("paginator", $set->getPaginator());
$this->setData("lects", $lects);
$this->renderView("__public/_lecturers/index.tpl");
}