本文整理汇总了PHP中professions::RecalcCatalogPositions方法的典型用法代码示例。如果您正苦于以下问题:PHP professions::RecalcCatalogPositions方法的具体用法?PHP professions::RecalcCatalogPositions怎么用?PHP professions::RecalcCatalogPositions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类professions
的用法示例。
在下文中一共展示了professions::RecalcCatalogPositions方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: old_getCatalog
//.........这里部分代码省略.........
// Общий каталог.
// В отличие от разделов тут жесткая связка с posrtf_choise -- это одно из условий нахождения в общем каталоге.
//переменные для добавления проверки по дополнительным специальностям
$join_add_spec = '';
$prof_choise_condition = "pc.prof_id = s.spec_orig";
$pattern = "#(s.spec_orig\\s+(IN\\s+\\([\\d,]+\\)))#";
$order_add_spec = "";
$order_add_spec_field = "";
if (preg_match($pattern, $filter_where, $m)) {
$filter_where = preg_replace($pattern, "(\n \$1 \n OR (sa.prof_id \$2 AND s.is_pro = 't' ) -- Только у ПРО учитываем ДОП специализацию, тк отменили платные специализации\n OR (sp.prof_id \$2 )\n )", $filter_where);
$join_add_spec = "LEFT JOIN \n spec_add_choise sa\n ON sa.user_id = s.uid\n \n LEFT JOIN \n spec_paid_choise sp\n ON sp.user_id = s.uid";
$prof_choise_condition = "(\n pc.prof_id = s.spec_orig\n OR pc.prof_id = sa.prof_id\n OR pc.prof_id = sp.prof_id\n )";
//$order_add_spec = "aso DESC, ";
$order_add_spec_field = "CAST(s.spec_orig {$m[2]} AS integer) AS aso, ";
}
$distinct = array_map('trim', array_filter(explode(',', str_replace(array('DESC', 'ASC', 'descr', 'asc'), '', $order))));
$distinct = $distinct ? implode(", ", $distinct) . "," : "";
// Сортировка фрилансеров внутри специализаии верхнего уровня по подуровням
$spec_case_order = '';
if (isset($m[2]) && $m[2]) {
$spec_case_order = ", CASE WHEN s.spec_orig {$m[2]} THEN 1 ELSE 2 END";
$specs_list = "p.prof_id {$m[2]}";
}
$fb_on_prof = 0;
if ($filter['prof']) {
if (count($filter['prof'][0]) > 0) {
$group_ids = array_keys($filter['prof'][0]);
$fb_on_prof = $group_ids[0];
}
}
$fb_join = "LEFT JOIN freelancer_binds fb ON fb.user_id = s.uid AND fb.prof_id = {$fb_on_prof} AND fb.is_spec = FALSE AND fb.status = TRUE AND fb.date_stop > NOW()";
$sql = "\n SELECT s.*,\n city.city_name as str_city, country.country_name as str_country, sbr_meta.completed_cnt,\n p.name as profname, p.is_text,\n rating_get(s.rating, s.is_pro, s.is_verify, s.is_profi) as t_rating\n {$uc_cols['OUTER']}\n {$fb_cols}\n FROM (\n \tSELECT s.* FROM (\n SELECT DISTINCT ON (s.is_pro, {$distinct} s.uid) s.*, s.cost_hour as frl_cost_hour, s.cost_type_hour as frl_cost_type_hour, {$order_add_spec_field}\n (COALESCE(pc.cost_hour, 0) = 0) as cost_hour_is_0, pc.cost_hour, pc.cost_from, pc.cost_type, pc.cost_1000, pc.cost_type_hour as pc_cost_type_hour\n {$cost_fm}\n {$uc_cols['INNER']}\n FROM {$fu_table} s\n {$join_add_spec}\n {$uc_join['INNER']}\n INNER JOIN\n portf_choise pc\n ON {$prof_choise_condition}\n AND pc.user_id = s.uid\n {$filter_join}\n WHERE s.is_banned = '0' {$filter_where} AND ( s.cat_show = 't' OR s.is_pro = 'f' )\n ) as s\n ) as s \n {$uc_join['OUTER']}\n {$fb_join}\n LEFT JOIN\n professions p\n ON p.id = s.spec\n LEFT JOIN\n \tcountry \n ON country.id = s.country\n LEFT JOIN\n \tsbr_meta \n ON sbr_meta.user_id = s.uid\n LEFT JOIN\n \tcity \n ON city.id = s.city\n ORDER BY (fb.id IS NULL)::boolean ASC, fb.date_start DESC, s.is_pro DESC {$spec_case_order} {$order}, {$order_add_spec} s.uid\n LIMIT {$limit} OFFSET {$offset}\n ";
$countSql = self::_createMainCountSql($filter_where, $filter_join, $join_add_spec);
}
if (!$filter_where) {
$memBuff = new memBuff();
$DB->setTimeout(90);
$frls = $memBuff->getSql($error, $sql, self::CATALOG_MEM_LIFE);
$DB->setTimeout();
if ($error || !$frls) {
return NULL;
}
if (!$prof_id && !$offset && !$memBuff->getBWasMqUsed()) {
professions::RecalcCatalogPositions();
}
$DB->setTimeout(90);
$count_arr = $memBuff->getSql($error, $countSql, self::CATALOG_MEM_LIFE);
$DB->setTimeout();
$count = $count_arr[0]['count'];
$size = sizeof($frls);
if ($prof_id && !$memBuff->getSqlBWasMqUsed && !$filter_where) {
professions::UpdateProfessionCount($or_prof, $count, $count_arr[0]['payed']);
}
} else {
$DB->setTimeout(90);
$frls = $DB->rows($sql);
$DB->setTimeout();
$error = $DB->error;
if ($error || !$frls) {
return NULL;
}
$DB->setTimeout(90);
$count_arr = $DB->rows($countSql);
//$memBuff->getSql($error, $countSql, 1800);
$DB->setTimeout();
$count = $count_arr[0]['count'];
$size = sizeof($frls);
//@todo: это никогда не срабатывает чтоли?
if ($prof_id && !$filter_where) {
professions::UpdateProfessionCount($or_prof, $count, $count_arr[0]['payed']);
}
}
foreach ($frls as $row) {
$frl_ids[] = $row['uid'];
}
$join_blocked = ' LEFT JOIN portfolio_blocked pb ON p.id = pb.src_id ';
$where_blocked = ' AND pb.src_id IS NULL ';
$sql = "SELECT p.id, p.user_id, p.name, p.descr, p.pict, p.prev_pict, p.show_preview, p.norder, p.prev_type, p.is_video\n FROM portfolio p\n INNER JOIN\n portf_choise pc\n ON pc.user_id = p.user_id\n AND pc.prof_id = p.prof_id \n " . ($prof_id ? '' : 'INNER JOIN freelancer f ON f.uid = p.user_id') . "\n {$join_blocked} \n WHERE p.user_id IN (" . implode(',', $frl_ids) . ")\n ";
if ($specs_list) {
$sql .= " AND {$specs_list}";
} else {
$sql .= " AND p.prof_id = " . ($prof_id ? "'{$or_prof}'" : 'f.spec_orig');
}
$sql .= " AND p.first3 = true {$where_blocked} ORDER BY p.user_id, p.norder";
if (!$filter_where) {
if ($ret = $memBuff->getSql($error, $sql, 600, true)) {
foreach ($ret as $row) {
$works[$row['user_id']][] = $row;
}
}
} else {
$ret = $DB->rows($sql);
if ($ret) {
foreach ($ret as $row) {
$works[$row['user_id']][] = $row;
}
}
}
return $frls;
}