Changeset 15139
- Timestamp:
- 2007/07/27 11:21:45 (17 years ago)
- Location:
- branches/feature-module-update
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/feature-module-update/data/class/db/SC_DB_MasterData.php
r15135 r15139 94 94 $sqlVal = array($columns[0] => $key, 95 95 $columns[1] => $val, 96 $columns[2] => $i);96 $columns[2] => (string) $i); 97 97 $this->objQuery->insert($name, $sqlVal); 98 98 $i++; … … 130 130 // マスタデータを削除 131 131 $this->deleteMasterData($name, false); 132 132 133 // マスタデータを追加 133 134 $this->registMasterData($name, $columns, $masterData, false); 135 134 136 if ($autoCommit) { 135 137 $this->objQuery->commit(); 136 138 } 137 138 // キャッシュを消去 139 $this->clearCache($name); 140 // 新規にデータを取得してキャッシュ生成 141 $newData = $this->getMasterData($name, $columns); 142 return count($newData); 139 return count($masterData); 143 140 } 144 141 … … 155 152 function deleteMasterData($name, $autoCommit = true) { 156 153 $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; 158 166 } 159 167 … … 165 173 */ 166 174 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 } 168 179 } 169 180 -
branches/feature-module-update/test/class/db/SC_DB_MasterData_Test.php
r15135 r15139 42 42 $this->assertEquals($expected, $actual); 43 43 } 44 45 /** 46 * SC_DB_MasterData::updateMasterData() のテストケース 47 */ 48 function testUpdateMasterData() { 49 50 $columns = array("pref_id", "pref_name", "rank"); 51 $masterData = new SC_DB_MasterData_Ex(); 52 53 // Transaction を有効にするため接続しておく 54 $masterData->objQuery = new SC_Query(); 55 $masterData->objQuery->begin(); 56 57 $expected = array("10" => "北海道", "20" => "愛知", "30" => "岐阜"); 58 $masterData->updateMasterData("mtb_pref", $columns, $expected, false); 59 60 $actual = $masterData->getMasterData("mtb_pref", $columns); 61 62 $this->assertEquals($expected, $actual); 63 64 $masterData->objQuery->rollback(); 65 $masterData->clearCache("mtb_pref"); 66 } 44 67 } 45 68 ?>
Note: See TracChangeset
for help on using the changeset viewer.