Changeset 20349
- Timestamp:
- 2011/02/23 19:26:40 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/version-2_5-dev/data/class/pages/admin/system/LC_Page_Admin_System_Editdb.php
r20345 r20349 44 44 function init() { 45 45 parent::init(); 46 47 46 $this->tpl_mainpage = 'system/editdb.tpl'; 48 47 $this->tpl_subnavi = 'system/subnavi.tpl'; … … 53 52 54 53 /** 55 * フォームパラメータ初期化56 *57 * @return void58 */59 function initForm() {60 $objForm = new SC_FormParam();61 $objForm->addParam('モード', 'mode', INT_LEN, 'n', array('ALPHA_CHECK', 'MAX_LENGTH_CHECK'));62 $objForm->addParam('テーブル名', 'table_name');63 $objForm->addParam('カラム名', 'column_name');64 $objForm->addParam('インデックス', 'indexflag');65 $objForm->addParam('インデックス(変更後)', 'indexflag_new');66 $objForm->setParam($_POST);67 $this->objForm = $objForm;68 }69 70 /**71 54 * Page のプロセス. 72 55 * … … 84 67 */ 85 68 function action() { 86 //フォームの値を取得 87 $this->initForm(); 69 <<<<<<< .mine 70 71 ======= 72 >>>>>>> .r20348 73 // 認証可否の判定 74 SC_Utils_Ex::sfIsSuccess(new SC_Session()); 75 76 $objFormParam = new SC_FormParam(); 77 78 // パラメータの初期化 79 $this->initForm($objFormParam, $_POST); 80 88 81 89 82 switch($this->getMode()) { 90 83 case 'confirm' : 91 $this->lfDoChange(); 84 $message = $this->lfDoChange($objFormParam); 85 if (!is_array($message) && $message != "") { 86 $this->tpl_onload = $message; 87 } 92 88 break; 93 89 default: 94 90 break; 95 91 } 96 92 97 93 //インデックスの現在値を取得 … … 108 104 } 109 105 110 function lfGetTargetData() { 111 $objQuery = new SC_Query(); 112 $arrIndexFlag = $this->objForm->getValue('indexflag'); 113 $arrIndexFlagNew = $this->objForm->getValue('indexflag_new'); 114 $arrTableName = $this->objForm->getValue('table_name'); 115 $arrColumnName =$this->objForm->getValue('column_name'); 106 /** 107 * フォームパラメータ初期化 108 * 109 * @param object $objFormParam 110 * @param array $arrParams $_POST値 111 * @return void 112 */ 113 function initForm(&$objFormParam, &$arrParams) { 114 115 $objFormParam->addParam('モード', 'mode', INT_LEN, 'n', array('ALPHA_CHECK', 'MAX_LENGTH_CHECK')); 116 $objFormParam->addParam('テーブル名', 'table_name'); 117 $objFormParam->addParam('カラム名', 'column_name'); 118 $objFormParam->addParam('インデックス', 'indexflag'); 119 $objFormParam->addParam('インデックス(変更後)', 'indexflag_new'); 120 $objFormParam->setParam($arrParams); 121 122 } 123 124 function lfDoChange(&$objFormParam) { 125 $objQuery =& SC_Query::getSingletonInstance(); 126 $arrTarget = $this->lfGetTargetData($objFormParam); 127 $message = ""; 128 if(is_array($arrTarget) && count($arrTarget) == 0) { 129 $message = "window.alert('変更対象となるデータはありませんでした。');"; 130 return $message; 131 } elseif(!is_array($arrTarget) && $arrTarget != "") { 132 return $arrTarget; // window.alert が返ってきているはず。 133 } 134 135 // 変更対象の設定変更 136 foreach($arrTarget as $item) { 137 $index_name = $item['table_name'] . '_' . $item['column_name'] . "_key"; 138 $arrField = array( 'fields' => array($item['column_name'] => array())); 139 if($item['indexflag_new'] == '1') { 140 $objQuery->createIndex($item['table_name'], $index_name, $arrField); 141 }else{ 142 $objQuery->dropIndex($item['table_name'], $index_name); 143 } 144 } 145 $message = "window.alert('インデックスの変更が完了しました。');"; 146 return $message; 147 } 148 149 function lfGetTargetData(&$objFormParam) { 150 $objQuery =& SC_Query::getSingletonInstance(); 151 $arrIndexFlag = $objFormParam->getValue('indexflag'); 152 $arrIndexFlagNew = $objFormParam->getValue('indexflag_new'); 153 $arrTableName = $objFormParam->getValue('table_name'); 154 $arrColumnName = $objFormParam->getValue('column_name'); 116 155 $arrTarget = array(); 156 $message = ""; 157 117 158 // 変更されている対象を走査 118 159 for($i = 1; $i <= count($arrIndexFlag); $i++) { … … 131 172 if(count($arrErr) != 0) { 132 173 // 通常の送信ではエラーにならないはずです。 133 $ this->tpl_onload= "window.alert('不正なデータがあったため処理を中断しました。');";134 return ;174 $message = "window.alert('不正なデータがあったため処理を中断しました。');"; 175 return $message; 135 176 } 136 177 if($param['indexflag'] != $param['indexflag_new']) { … … 144 185 } 145 186 146 function lfDoChange() { 147 $objQuery = new SC_Query(); 148 $arrTarget = $this->lfGetTargetData(); 149 if(count($arrTarget) == 0) { 150 $this->tpl_onload = "window.alert('変更対象となるデータはありませんでした。');"; 151 return; 152 } 153 154 // 変更対象の設定変更 155 foreach($arrTarget as $item) { 156 $index_name = $item['table_name'] . '_' . $item['column_name'] . "_key"; 157 $arrField = array( 'fields' => array($item['column_name'] => array())); 158 if($item['indexflag_new'] == '1') { 159 $objQuery->createIndex($item['table_name'], $index_name, $arrField); 160 }else{ 161 $objQuery->dropIndex($item['table_name'], $index_name); 162 } 163 } 164 $this->tpl_onload = "window.alert('インデックスの変更が完了しました。');"; 165 } 187 166 188 167 189 /** … … 173 195 { 174 196 // データベースからインデックス設定一覧を取得する 175 $objQuery = new SC_Query();197 $objQuery =& SC_Query::getSingletonInstance(); 176 198 $objQuery->setOrder("table_name, column_name"); 177 199 $arrIndexList = $objQuery->select("table_name , column_name , recommend_flg, recommend_comment", "dtb_index_list");
Note: See TracChangeset
for help on using the changeset viewer.