118 $dbConnection = Main\HttpApplication::getConnection();
123 $table =
'b_tmp_ukrain_region';
126 $table =
'b_tmp_ukrain_area';
129 $table =
'b_tmp_ukrain_city';
132 $table =
'b_tmp_ukrain_village';
136 $item = $dbConnection->query(
"select NAME, NAME_RU from ".$table.
" where ID = '".intval($id).
"'")->fetch();
138 $replaceFrom = array(
'обл.',
'р-н');
139 $replaceTo = array(
'область',
'район');
142 'ua' => array(
'NAME' => str_replace($replaceFrom, $replaceTo, $item[
'NAME'])),
143 'ru' => array(
'NAME' => str_replace($replaceFrom, $replaceTo, $item[
'NAME_RU']))
149 $key = intval($params[
'AREA_ID']) ? $params[
'AREA_ID'] : $params[
'REGION_ID'];
151 if(!isset($this->settlementParent[$key]))
153 if(!isset($this->settlementParent[$params[
'REGION_ID']]))
157 'ID' => $params[
'REGION_ID'],
161 $this->settlementParent[$params[
'REGION_ID']] = $code;
164 if(intval($params[
'AREA_ID']))
166 if(!isset($this->settlementParent[$params[
'AREA_ID']]))
170 'ID' => $params[
'AREA_ID'],
171 'PARENT_CODE' => $this->settlementParent[$params[
'REGION_ID']],
174 $this->settlementParent[$key] = $code;
179 return $this->settlementParent[$key];
184 if(isset($options[
'NEXT_FREE_CODE']))
185 $this->exportOffset = intval($options[
'NEXT_FREE_CODE']);
187 $dbConnection = Main\HttpApplication::getConnection();
190 $res = $dbConnection->query(
'select ID, ZIP, ZIP_TO, TYPE_ID, CITY_ID, REGION_ID, AREA_ID, VILLAGE_ID from b_tmp_ukrain_settlement');
191 while($item = $res->fetch())
194 'REGION_ID' => $item[
'REGION_ID'],
195 'AREA_ID' => $item[
'AREA_ID']
202 if(intval($item[
'CITY_ID']) && intval($item[
'VILLAGE_ID']))
207 $code = $this->settlementParent[$item[
'CITY_ID']];
208 $id = $item[
'VILLAGE_ID'];
212 elseif(intval($item[
'CITY_ID']))
215 $id = $item[
'CITY_ID'];
218 $this->settlementParent[$key] = $this->
addNode(array(
220 'TYPE_CODE' => $type,
221 'PARENT_CODE' => $code,
222 'NAME' => $this->
getNames($id, $type),
223 'ZIP' => $item[
'ZIP'],
224 'ZIP_TO' => $item[
'ZIP_TO'],