function getWiki() { if (!isset($_SESSION['wiki']['city'])) { //获取城市--通过ip $city = getCurrentCity(); if (!$city) { $_SESSION['wiki']['city'] = $city = '深圳'; $_SESSION['wiki']['cityId'] = 77; } $data['city'] = $city; $weather = getWeather($city); $data['weather'] = $_SESSION['wiki']['weather']; echo json_encode($data); exit; } else { $data['city'] = $_SESSION['wiki']['city']; if (!isset($_SESSION['wiki']['weather'])) { getWeather($data['city']); } $data['weather'] = $_SESSION['wiki']['weather']; echo json_encode($data); exit; } }
function category() { $prefix = C("DB_PREFIX"); if (!isset($_SESSION['wiki']['cityId'])) { $city = getCurrentCity(); $cityId = $city['cityId']; } else { $cityId = $_SESSION['wiki']['cityId']; } if (!isset($_GET['catid'])) { $this->error("您查看的页面不存在"); exit; } $catid = intval($_GET['catid']); $cate = sp_sql_cate($catid); if ($cate) { foreach ($cate as $v) { $catid .= ',' . $v['id']; } } $count = M("Jobs")->where("catid in ({$catid}) and status=2")->count(); $page = page($count, 10); $where = "j.work_city={$cityId} and j.catid in ({$catid}) and j.status=2 "; $sql = "select j.*,c.name,n.nature_name,r.name as cityName from {$prefix}jobs j LEFT JOIN {$prefix}cate c on j.catid=c.id LEFT JOIN "; $sql .= " {$prefix}nature n on n.id=j.work_nature left join {$prefix}region r on r.id = j.work_city where {$where} order by j.refreshtime desc limit " . $page->firstRow . ',' . $page->listRows; // echo $sql;die(); $data = M()->query($sql); $this->assign('jobs', $data); $this->display(); }