Changeset 18355 for branches/comu-ver2/data/class/util/SC_Utils.php
- Timestamp:
- 2009/10/29 21:10:03 (17 years ago)
- File:
-
- 1 edited
-
branches/comu-ver2/data/class/util/SC_Utils.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/comu-ver2/data/class/util/SC_Utils.php
r18293 r18355 2206 2206 return defined('INSTALL_FUNCTION') && INSTALL_FUNCTION; 2207 2207 } 2208 2209 // 郵便番号から住所の取得 2210 function sfGetAddress($zipcode) { 2211 2212 $conn = new SC_DBconn(ZIP_DSN); 2213 2214 $masterData = new SC_DB_MasterData_Ex(); 2215 $arrPref = $masterData->getMasterData("mtb_pref", array("pref_id", "pref_name", "rank")); 2216 // インデックスと値を反転させる。 2217 $arrREV_PREF = array_flip($arrPref); 2218 2219 // 郵便番号検索文作成 2220 $zipcode = mb_convert_kana($zipcode ,"n"); 2221 $sqlse = "SELECT state, city, town FROM mtb_zip WHERE zipcode = ?"; 2222 2223 $data_list = $conn->getAll($sqlse, array($zipcode)); 2224 if (empty($data_list)) return array(); 2225 2226 /* 2227 総務省からダウンロードしたデータをそのままインポートすると 2228 以下のような文字列が入っているので 対策する。 2229 ・(1・19丁目) 2230 ・以下に掲載がない場合 2231 */ 2232 $town = $data_list[0]['town']; 2233 $town = ereg_replace("(.*)$","",$town); 2234 $town = ereg_replace("以下に掲載がない場合","",$town); 2235 $data_list[0]['town'] = $town; 2236 $data_list[0]['state'] = $arrREV_PREF[$data_list[0]['state']]; 2237 2238 return $data_list; 2239 } 2208 2240 } 2209 2241 ?>
Note: See TracChangeset
for help on using the changeset viewer.
