/** * Add state and region to city container. * * @param array $currentCity - description of city name, socr and code * @param PearDatabase $db */ private function selectCityStateAndRegion(&$currentCity, $db) { /* Get lelvel 1 location for current entity of level 3-4 */ $firstLevelLocationCode = substr($currentCity["cityCode"], 0, 2) . "00000000000"; $firstLevelLocationResult = $db->pquery("select name, socr FROM sp_kladr WHERE code=?", array($firstLevelLocationCode)); if ($firstLevelLocationRow = $db->fetch_row($firstLevelLocationResult)) { $currentCity["stateName"] = $firstLevelLocationRow["name"]; $currentCity["stateSocr"] = $firstLevelLocationRow["socr"]; } /* Get lelvel 2 location for current entity of level 3-4 */ $currentCity["regionName"] = ""; $currentCity["regionSocr"] = ""; $secondLevelLocationCode = substr($currentCity["cityCode"], 0, 5) . "00000000"; $secondLevelLocationResult = $db->pquery("select name, socr FROM sp_kladr WHERE code=? " . "AND socr IN (select scname FROM sp_kladr_socrbase WHERE level=2)", array($secondLevelLocationCode)); if ($secondLevelLocationRow = $db->fetch_row($secondLevelLocationResult)) { $currentCity["regionName"] = $secondLevelLocationRow["name"]; $currentCity["regionSocr"] = $secondLevelLocationRow["socr"]; } }