continue; } if ($item['l_geo_city'] == 'Санкт-Петербург') { updateAds($item['l_geo_city'], 1059979, 508324, $db); continue; } /*$isSet = checkIsSet($item['l_geo_city'], $db); if($isSet === true) {continue;}*/ $sql = 'SELECT id, code, name FROM ru_geo.kladr WHERE name= :name AND socr="г" AND SUBSTRING(code,12,2)="00"'; $stmt = $db->prepare($sql); $stmt->bindParam(':name', $item['l_geo_city'], PDO::PARAM_STR); $res = $stmt->execute(); if ($res === false) { print_r($stmt->errorInfo()); die; } $stmt->setFetchMode(PDO::FETCH_ASSOC); $kladrItems = $stmt->fetchAll(); $stmt->closeCursor(); if (count($kladrItems) > 1 || empty($kladrItems)) { echo "Name: " . $item['l_geo_city'] . ". More then 1 or empty\n"; continue; } $city_id = $kladrItems[0]['id']; $region_id = getRegionId($kladrItems[0]['code'], $db); if ($region_id === false) { echo "Empty region id\n"; continue; } updateAds($item['l_geo_city'], $city_id, $region_id, $db); }
$stmt = $db->prepare($sql); $stmt->bindParam(':name', $where['name'], PDO::PARAM_STR); $stmt->bindParam(':socrname', $where['socrname'], PDO::PARAM_STR); if (!empty($item['region_code'])) { $parentCode = substr($item['region_code'], 0, 2); $stmt->bindParam(':parent_code', $parentCode, PDO::PARAM_STR, 2); } $res = $stmt->execute(); if ($res === false) { print_r($stmt->errorInfo()); die; } $stmt->setFetchMode(PDO::FETCH_ASSOC); $kladrItems = $stmt->fetchAll(); $stmt->closeCursor(); if (count($kladrItems) > 1 || empty($kladrItems)) { echo "Name: " . $item['l_geo_city'] . ". More then 1 or empty\n"; continue; } $city_id = $kladrItems[0]['id']; if (empty($region_id)) { $region_id = getRegionId($kladrItems[0]['code'], $db); if ($region_id === false) { echo "Empty region id\n"; continue; } } $subregion_id = getRegionId($kladrItems[0]['code'], $db, 'subregion'); $subregion_id = $subregion_id === false ? null : $subregion_id; updateAds($item['l_geo_city'], $city_id, $subregion_id, $region_id, $item['old_region_id'], $db); }