Ignore:
Timestamp:
2007/07/27 11:21:45 (17 years ago)
Author:
nanasess
Message:

トランザクションとキャッシュまわり修正

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/feature-module-update/data/class/db/SC_DB_MasterData.php

    r15135 r15139  
    9494            $sqlVal = array($columns[0] => $key, 
    9595                            $columns[1] => $val, 
    96                             $columns[2] => $i); 
     96                            $columns[2] => (string) $i); 
    9797            $this->objQuery->insert($name, $sqlVal); 
    9898            $i++; 
     
    130130        // マスタデータを削除 
    131131        $this->deleteMasterData($name, false); 
     132 
    132133        // マスタデータを追加 
    133134        $this->registMasterData($name, $columns, $masterData, false); 
     135 
    134136        if ($autoCommit) { 
    135137            $this->objQuery->commit(); 
    136138        } 
    137  
    138         // キャッシュを消去 
    139         $this->clearCache($name); 
    140         // 新規にデータを取得してキャッシュ生成 
    141         $newData = $this->getMasterData($name, $columns); 
    142         return count($newData); 
     139        return count($masterData); 
    143140    } 
    144141 
     
    155152    function deleteMasterData($name, $autoCommit = true) { 
    156153        $this->objQuery = new SC_Query(); 
    157         return $this->objQuery->delete($name); 
     154        if ($autoCommit) { 
     155            $this->objQuery->begin(); 
     156        } 
     157 
     158        // DB の内容とキャッシュをクリア 
     159        $result = $this->objQuery->delete($name); 
     160        $this->clearCache($name); 
     161 
     162        if ($autoCommit) { 
     163            $this->objQuery->commit(); 
     164        } 
     165        return $result; 
    158166    } 
    159167 
     
    165173     */ 
    166174    function clearCache($name) { 
    167         unlink(MASTER_DATA_DIR . $name . ".php"); 
     175        $masterDataFile = MASTER_DATA_DIR . $name . ".php"; 
     176        if (is_file($masterDataFile)) { 
     177            unlink($masterDataFile); 
     178        } 
    168179    } 
    169180 
Note: See TracChangeset for help on using the changeset viewer.