本文整理汇总了PHP中professions::GetProfessionsByUser2方法的典型用法代码示例。如果您正苦于以下问题:PHP professions::GetProfessionsByUser2方法的具体用法?PHP professions::GetProfessionsByUser2怎么用?PHP professions::GetProfessionsByUser2使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类professions
的用法示例。
在下文中一共展示了professions::GetProfessionsByUser2方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getProjectPromo
public function getProjectPromo($uid)
{
global $DB;
require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/professions.php";
$user_specs = professions::GetProfessionsByUser2($uid, true);
if ($user_specs) {
$category = implode(", ", $user_specs['prof_group']);
$subcategory = implode(", ", $user_specs['prof']);
}
$sql = "SELECT \n p.id, p.post_date as create_date, p.cost, p.priceby, p.currency, p.name AS project_name, NULL AS cat_name, NULL AS subcat_name,\n p.kind, p.end_date, p.budget_type,\n co.country_name, ci.city_name, p.descr, e.uname as e_name, e.usurname as e_surname, e.login as e_login \n FROM projects p\n INNER JOIN employer e ON e.uid = p.user_id \n LEFT JOIN country co ON co.id = p.country \n LEFT JOIN city ci ON ci.id = p.city \n LEFT JOIN projects_blocked pb ON pb.project_id = p.id \n WHERE \n p.pro_only = true \n AND pb.project_id IS NULL\n AND p.cost > 0\n AND budget_type = 3\n AND p.closed = false\n AND p.kind <> 9 \n AND e.is_banned < 1::bit\n AND p.post_date > DATE_TRUNC('hour', now() - interval '2 day')\n " . (!empty($user_specs) ? " AND EXISTS (SELECT 1 from project_to_spec WHERE project_id = p.id AND (subcategory_id IN ({$subcategory}) OR ( category_id IN ({$category}) AND subcategory_id = 0 )))" : "") . "\n ORDER BY RANDOM() LIMIT 20";
$result = $DB->cache(300)->rows($sql);
if ($result) {
if (count($result) > 3) {
//выбираем произвольно первые 3 проекта из запроса
$rnd = array_rand($result, 3);
return array($result[$rnd[0]], $result[$rnd[1]], $result[$rnd[2]]);
} else {
return $result;
}
} else {
return false;
}
}