Skip to content

Instantly share code, notes, and snippets.

@kpion
Last active July 9, 2017 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kpion/a21ad1b1dcf8c15b8a36cc9e68be3425 to your computer and use it in GitHub Desktop.
Save kpion/a21ad1b1dcf8c15b8a36cc9e68be3425 to your computer and use it in GitHub Desktop.
public function defaultMethod() {
lib::$view->assign("pageTemplate", $this->templateDir."cities.tpl");
$cityId = 2;
$defaultCityIds = '2, 3, 7, 12';
$cityIds = null;
if (isset($_GET['city']) && !empty($_GET['city'])) {
$cityId = $_GET['city'];
$cityIds = $_GET['city'];
}else{
$cityIds = $defaultCityIds;
}
$city = lib::$db->GetAll("SELECT * FROM cities WHERE id_city = $cityId");
$cities = lib::$db->GetAll("SELECT * FROM cities WHERE id_city IN ($defaultCityIds)");
$isLogged = auth::isLoggedIn();
lib::$view->assign("isLogged", $isLogged);
lib::$view->assign("city", $city[0]);
lib::$view->assign("cities", $cities);
$this->getProfiles($cityId);
$this->getSpaces($cityId);
$this->getJobs($cityIds);
$this->getEvents($cityId);
}
/**
@param $cityIds - one ID (integer) or many, like string - "1,2,3"
/*
public function getJobs($cityIds) {
if(is_array($cityIds)){
$cityIds = implode(',',$cityIds);
}
$jobs = lib::$db->GetAll("SELECT
j.*,
s.name AS space,
s.page_url AS space_url
FROM job_posts AS j
LEFT JOIN spaces AS s ON j.id_space = s.id_space
WHERE j.id_city IN ($cityIds)
AND j.id_plan IN (1, 2)
LIMIT 3");
lib::$view->assign("jobs", $jobs);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment