本文整理汇总了PHP中freelancer::createCatalogFilterSql方法的典型用法代码示例。如果您正苦于以下问题:PHP freelancer::createCatalogFilterSql方法的具体用法?PHP freelancer::createCatalogFilterSql怎么用?PHP freelancer::createCatalogFilterSql使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类freelancer
的用法示例。
在下文中一共展示了freelancer::createCatalogFilterSql方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setResults
function setResults()
{
global $DB;
require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/freelancer.php";
if ($filter = $this->isAdvanced()) {
foreach ($this->matches as $val) {
$frl_ids[] = $val;
}
$page = $this->_advanced_page;
$limit = $this->_advanced_limit;
$offset = 0;
if ($page > 0) {
$offset = ($page - 1) * $limit;
}
$this->_offset = $offset;
//if(isset($filter['nt_negative'])) $filter['not_negative'] = $filter['nt_negative'];
$prof_id = is_array($filter['prof'][1]) ? array_keys($filter['prof'][1]) : array();
$order_by_spec_orign = "";
if (count($prof_id)) {
$order_by_spec_orign = "s.spec IN (" . join(", ", $prof_id) . ") DESC,";
}
$prof = $filter['prof'];
unset($filter['prof']);
$fprms = freelancer::createCatalogFilterSql($filter, 0);
$filter_sql = $inner_sql = '';
if ($fprms !== -1) {
list($filter_sql, $inner_sql) = $fprms;
if ($filter_sql) {
$filter_sql = ' AND ' . $filter_sql;
}
}
$sql = "SELECT \n COUNT(u.uid) as cnt \n FROM users u\n LEFT JOIN \n freelancer s ON s.uid = u.uid\n LEFT JOIN\n portf_choise pc ON ( pc.prof_id = s.spec_orig AND pc.user_id = s.uid )\n LEFT JOIN\n users_counters uc ON ( uc.user_id = u.uid )\n {$inner_sql} \n WHERE \n u.uid IN (" . implode(", ", $frl_ids) . ") \n AND \n u.is_banned = '0'\n {$filter_sql} \n LIMIT 1;";
$this->total = $DB->val($sql);
$sql = "SELECT \n u.uid as uid, \n u.photo, \n u.role, \n u.is_pro, \n u.is_profi,\n u.is_team, \n u.is_pro_test, \n u.info_for_reg, \n p.name as name_prof, \n u.login, \n u.uname, \n u.usurname,\n u.email, \n u.skype, \n s.site, \n ctr.country_name, \n ct.city_name, \n s.spec_text, \n s.resume, \n s.konk, \n s.blocks, \n s.status_type, \n s.cost_month, \n s.cost_hour AS frl_cost_hour, \n s.cost_type_hour as frl_cost_type_hour,\n s.in_office, \n s.exp, \n s.tabs,\n \n uc.sbr_opi_plus, \n uc.sbr_opi_minus, \n uc.sbr_opi_null,\n \n pc.cost_from, \n pc.cost_to, \n pc.cost_1000, \n pc.cost_type, \n uc.ops_emp_null + uc.ops_frl_null AS se, \n uc.ops_emp_plus + uc.ops_frl_plus AS sg, \n uc.ops_emp_minus + uc.ops_frl_minus AS sl, \n s.cost_type_hour, \n s.cost_type_month, \n rating_get(s.rating, s.is_pro, s.is_verify, s.is_profi) as t_rating,\n (add_spec.additional_specs || ', ' || COALESCE(p_spec.paid_specs, '')) AS additional_specs,\n -- get_additional_specs_as_string(u.uid) AS additional_spec,\n \n (uc.paid_advices_cnt + uc.sbr_opi_plus + uc.tu_orders_plus + uc.projects_fb_plus) AS total_opi_plus,\n (uc.sbr_opi_null) AS total_opi_null,\n (uc.sbr_opi_minus + uc.tu_orders_minus + uc.projects_fb_minus) AS total_opi_minus,\n \n COALESCE(smeta.completed_cnt, 0) + COALESCE(uc.reserves_completed_cnt, 0) AS completed_cnt -- старые БС + новые БС\n \n FROM users u\n LEFT JOIN freelancer s ON s.uid = u.uid\n LEFT JOIN portf_choise pc ON ( pc.prof_id = s.spec_orig AND pc.user_id = s.uid )\n LEFT JOIN professions p ON p.id = s.spec AND p.id > 0\n LEFT JOIN users_counters uc ON uc.user_id = u.uid\n LEFT JOIN country ctr ON ctr.id = s.country AND ctr.id > 0\n LEFT JOIN city ct ON ct.id = s.city AND ct.id > 0\n LEFT JOIN sbr_meta AS smeta ON smeta.user_id = u.uid -- старые БС\n LEFT JOIN \n ( \n SELECT \n array_to_string(array_agg(p.name), ', '::text) AS additional_specs, \n sa.user_id AS uid\n FROM spec_add_choise AS sa\n LEFT JOIN professions AS p ON p.id = prof_id\n\t GROUP BY sa.user_id\n ) AS add_spec ON add_spec.uid = u.uid\n LEFT JOIN \n ( \n SELECT \n array_to_string(array_agg(p.name), ', '::text) AS paid_specs, \n sp.user_id AS uid\n FROM spec_paid_choise AS sp\n LEFT JOIN professions AS p ON p.id = prof_id\n\t GROUP BY sp.user_id\n ) AS p_spec ON p_spec.uid = u.uid \n \n {$inner_sql}\n WHERE\n u.uid IN (" . implode(", ", $frl_ids) . ") AND \n u.is_banned = '0' \n {$filter_sql}\n ORDER BY u.is_pro DESC, {$order_by_spec_orign} s.rating DESC, u.uid \n LIMIT {$limit} OFFSET {$offset}";
//echo "<pre>".$sql;
$this->results = $DB->rows($sql);
} else {
$this->results = $this->getRecords('is_pro DESC, rating DESC, id');
}
if ($this->results) {
$frl_ids_map = array();
$tu_frl_ids = array();
foreach ($this->results as $key => $row) {
$frl_ids[] = $row['uid'];
$frl_ids_map[$row['uid']] = $key;
//Если вкладка ТУ выключена то сразу исключаем такие UID
if (substr($row['tabs'], 7, 1) == 1) {
$tu_frl_ids[$key] = $row['uid'];
}
}
$uid = isset($_SESSION["uid"]) ? $_SESSION["uid"] : 0;
$is_spec = isset($prof[0]);
$categoty_id = $is_spec ? key($prof[0]) : 0;
$prof_id = !$is_spec && isset($prof[1]) ? key($prof[1]) : 0;
//print_r($current_categoty_id);
//exit;
//Получение пользовательский превью работ/услуг
require_once ABS_PATH . '/freelancers/widgets/FreelancersPreviewWidget.php';
require_once ABS_PATH . '/freelancers/models/FreelancersPreviewModel.php';
$freelancersPreviewModel = new FreelancersPreviewModel();
$list = $freelancersPreviewModel->getListByUids($frl_ids, $categoty_id, $prof_id);
$tmp_tu_uids = $tu_frl_ids;
foreach ($list as $item) {
//Если отключена вкладка ТУ то их исключаем
if (!$item || $item->type == FreelancersPreviewModel::TYPE_TU && !in_array($item->user_id, $tmp_tu_uids)) {
continue;
}
//Инициализируем данные юзера в работе/услуге пока только логин нужен
$key = $frl_ids_map[$item->user_id];
$item->setUser(array('login' => $this->results[$key]['login']));
//Инитим виджет если его нет
if (!isset($this->results[$key]['preview'])) {
$this->results[$key]['preview'] = new FreelancersPreviewWidget();
}
//Добавляем работу в виджет
$this->results[$key]['preview']->addItem($item);
//Исключаем из дальнейшей обработки
unset($frl_ids[$key], $tu_frl_ids[$key]);
}
//------------------------------------------------------------------
$this->works = null;
if ($frl_ids) {
$this->works = $this->getUsersWorks($frl_ids, $uid);
}
//------------------------------------------------------------------
//Если у пользователя не отображатся портфолио
//то можно показать 3 последнии ТУ
$exist_uids = $this->works ? array_keys($this->works) : array();
$tu_uids = array_diff($frl_ids, $exist_uids);
if ($tu_uids) {
require_once ABS_PATH . '/tu/models/TServiceModel.php';
$tserviceModel = new TServiceModel();
if ($list = $tserviceModel->getListByUids($tu_uids, 3, freelancer::CATALOG_PORTFOLIO_MEM_LIFE)) {
$current_user_tu_ids = array();
foreach ($list as $item) {
$key = $frl_ids_map[$item['user_id']];
$item['login'] = $this->results[$key]['login'];
$this->results[$key]['tservices'][] = $item;
if ($item['user_id'] == $uid) {
$current_user_tu_ids[] = $item['id'];
//.........这里部分代码省略.........
示例2: setResults
function setResults()
{
global $session, $DB;
if ($filter = $this->isAdvanced()) {
require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/projects.php";
require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/freelancer.php";
foreach ($this->matches as $val) {
$frl_ids[] = $val;
}
$page = $this->_advanced_page;
$limit = $this->_advanced_limit;
$offset = 0;
if ($page > 0) {
$offset = ($page - 1) * $limit;
}
$this->_offset = $offset;
//if(isset($filter['nt_negative'])) $filter['not_negative'] = $filter['nt_negative'];
$prof_id = is_array($filter['prof'][1]) ? array_keys($filter['prof'][1]) : array();
$order_by_spec_orign = "";
if (count($prof_id)) {
$order_by_spec_orign = "s.spec IN (" . join(", ", $prof_id) . ") DESC,";
}
//@todo: спорная операция так как в запрос не пойдут категории
//и вся надежда только на поиск по тексту от Сфинкса
//
//пока убираю
//
//unset($filter['prof']);
$fprms = freelancer::createCatalogFilterSql($filter, 0);
$filter_sql = $inner_sql = '';
if ($fprms !== -1) {
list($filter_sql, $inner_sql) = $fprms;
if ($filter_sql) {
$filter_sql = ' AND ' . $filter_sql;
}
}
$sql = "SELECT \n COUNT(u.uid) as cnt \n FROM users u\n LEFT JOIN \n freelancer s ON s.uid = u.uid\n LEFT JOIN\n portf_choise pc ON ( pc.prof_id = s.spec_orig AND pc.user_id = s.uid )\n LEFT JOIN\n users_counters uc ON ( uc.user_id = u.uid )\n {$inner_sql} \n WHERE \n u.uid IN (" . implode(", ", $frl_ids) . ") \n AND \n u.is_banned = '0'\n {$filter_sql} \n LIMIT 1;";
$this->total = $DB->val($sql);
$sql = "SELECT \n u.uid as id, \n u.photo, \n u.role, \n u.is_pro, \n u.is_profi, \n u.is_team, \n u.is_pro_test, \n u.info_for_reg, \n p.name as name_prof, \n u.login, \n u.uname, \n u.usurname, \n u.email, \n u.skype, \n s.site, \n ctr.country_name, \n ct.city_name, \n s.spec_text, \n s.resume, \n s.konk, \n s.blocks, \n s.status_type, \n s.cost_month, \n s.cost_hour, \n s.in_office, \n s.exp,\n pc.cost_from, \n pc.cost_to, \n pc.cost_1000, \n pc.cost_type, \n\n (uc.paid_advices_cnt + uc.ops_emp_plus + uc.ops_frl_plus + uc.sbr_opi_plus + uc.tu_orders_plus + uc.projects_fb_plus) AS all_opi_plus,\n (uc.ops_emp_null + uc.ops_frl_null + uc.sbr_opi_null) AS all_opi_null,\n (uc.ops_emp_minus + uc.ops_frl_minus + uc.sbr_opi_minus + uc.tu_orders_minus + uc.projects_fb_minus) AS all_opi_minus,\n\n s.cost_type_hour, \n s.cost_type_month, \n rating_get(s.rating, s.is_pro, s.is_verify, s.is_profi) as rating,\n (add_spec.additional_specs || ', ' || COALESCE(p_spec.paid_specs, '')) AS additional_specs\n -- get_additional_specs_as_string(u.uid) AS additional_spec\n\n FROM users u\n LEFT JOIN \n freelancer s ON s.uid = u.uid\n LEFT JOIN\n portf_choise pc ON ( pc.prof_id = s.spec_orig AND pc.user_id = s.uid )\n LEFT JOIN\n professions p ON p.id = s.spec AND p.id > 0\n LEFT JOIN\n users_counters uc ON uc.user_id = u.uid\n LEFT JOIN \n country ctr ON ctr.id = s.country AND ctr.id > 0\n LEFT JOIN \n city ct ON ct.id = s.city AND ct.id > 0\n\n LEFT JOIN ( SELECT array_to_string(array_agg(p.name), ', '::text) AS additional_specs, sa.user_id AS uid\n FROM spec_add_choise AS sa\n LEFT JOIN professions AS p ON p.id = prof_id\n\t GROUP BY sa.user_id) AS add_spec ON add_spec.uid = u.uid\n\n LEFT JOIN ( SELECT array_to_string(array_agg(p.name), ', '::text) AS paid_specs, sp.user_id AS uid\n FROM spec_paid_choise AS sp\n LEFT JOIN professions AS p ON p.id = prof_id\n\t GROUP BY sp.user_id) AS p_spec ON p_spec.uid = u.uid \n \n {$inner_sql}\n WHERE\n u.uid IN (" . implode(", ", $frl_ids) . ") \n AND \n u.is_banned = '0' \n {$filter_sql}\n ORDER BY u.is_pro DESC, {$order_by_spec_orign} s.rating DESC, u.uid \n LIMIT {$limit} OFFSET {$offset}";
//echo "<pre>".$sql;
$this->results = $DB->rows($sql);
if ($this->results) {
foreach ($this->results as $row) {
$filter_frl_ids[] = $row['id'];
}
if (count($filter_frl_ids) > 0) {
$this->works = $this->getUsersWorks($filter_frl_ids);
}
}
} else {
$this->results = $this->getRecords('is_pro DESC, rating DESC, id');
if ($this->results) {
foreach ($this->results as $row) {
$frl_ids[] = $row['id'];
}
if (count($frl_ids) > 0) {
$this->works = $this->getUsersWorks($frl_ids);
}
}
}
}