Ignore:
Timestamp:
2009/10/29 21:10:03 (14 years ago)
Author:
shutta
Message:

郵便番号から住所を取得する同一処理が複数箇所に記述されていたので、SC_Utilsにまとめた。

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/comu-ver2/data/class/pages/entry/LC_Page_Entry.php

    r18353 r18355  
    469469 
    470470                    if (@$this->arrForm['pref'] == "" && @$this->arrForm['addr01'] == "" && @$this->arrForm['addr02'] == "") { 
    471                         $address = $this->lfGetAddress($_REQUEST['zip01'].$_REQUEST['zip02']); 
     471                        $address = SC_Utils_Ex::sfGetAddress($_REQUEST['zip01'].$_REQUEST['zip02']); 
    472472                        $this->pref = @$address[0]['state']; 
    473473                        $this->addr01 = @$address[0]['city'] . @$address[0]['town']; 
     
    836836    // {{{ mobile functions 
    837837 
    838     // 郵便番号から住所の取得 
    839     function lfGetAddress($zipcode) { 
    840  
    841         $conn = new SC_DBconn(ZIP_DSN); 
    842  
    843         // 郵便番号検索文作成 
    844         $zipcode = mb_convert_kana($zipcode ,"n"); 
    845         $sqlse = "SELECT state, city, town FROM mtb_zip WHERE zipcode = ?"; 
    846  
    847         $data_list = $conn->getAll($sqlse, array($zipcode)); 
    848  
    849         // インデックスと値を反転させる。 
    850         $arrREV_PREF = array_flip($this->arrPref); 
    851  
    852         /* 
    853          総務省からダウンロードしたデータをそのままインポートすると 
    854          以下のような文字列が入っているので  対策する。 
    855          ・(1・19丁目) 
    856          ・以下に掲載がない場合 
    857         */ 
    858         $town =  $data_list[0]['town']; 
    859         $town = ereg_replace("(.*)$","",$town); 
    860         $town = ereg_replace("以下に掲載がない場合","",$town); 
    861         $data_list[0]['town'] = $town; 
    862         $data_list[0]['state'] = $arrREV_PREF[$data_list[0]['state']]; 
    863  
    864         return $data_list; 
    865     } 
    866  
    867838    //---- 入力エラーチェック 
    868839    function lfErrorCheck1($array) { 
Note: See TracChangeset for help on using the changeset viewer.