[Svn-src-all:1279] [version-2_5-dev 20168] #964 アクションからデータベース操作処理を除去

coelacanth admin @ mail.ec-cube.net
2011年 2月 15日 (火) 17:31:04 JST


Subversion committed to /home/svn/open 20168
http://svn.ec-cube.net/open_trac/changeset/20168
┌────────────────────────────┐
│更新者 :  coelacanth                                   │
│更新日時:  2011-02-15 17:31:03 +0900 (火, 15  2月 2011)│
└────────────────────────────┘

Log:
--------------------------------------------------------
#964 アクションからデータベース操作処理を除去

Changed:                      [U:修正,A:追加,D:削除]
--------------------------------------------------------
U   branches/version-2_5-dev/data/class/pages/admin/basis/LC_Page_Admin_Basis.php
U   branches/version-2_5-dev/data/class/pages/admin/basis/LC_Page_Admin_Basis_Delivery.php
U   branches/version-2_5-dev/data/class/pages/admin/basis/LC_Page_Admin_Basis_Holiday.php
U   branches/version-2_5-dev/data/class/pages/admin/basis/LC_Page_Admin_Basis_Kiyaku.php
U   branches/version-2_5-dev/data/class/pages/admin/basis/LC_Page_Admin_Basis_Mail.php
U   branches/version-2_5-dev/data/class/pages/admin/basis/LC_Page_Admin_Basis_Point.php
U   branches/version-2_5-dev/data/class/pages/admin/basis/LC_Page_Admin_Basis_Tradelaw.php
U   branches/version-2_5-dev/data/class/pages/admin/basis/LC_Page_Admin_Basis_ZipInstall.php

変更: branches/version-2_5-dev/data/class/pages/admin/basis/LC_Page_Admin_Basis.php
===================================================================
--- branches/version-2_5-dev/data/class/pages/admin/basis/LC_Page_Admin_Basis.php	2011-02-15 07:43:52 UTC (rev 20167)
+++ branches/version-2_5-dev/data/class/pages/admin/basis/LC_Page_Admin_Basis.php	2011-02-15 08:31:03 UTC (rev 20168)
@@ -79,12 +79,11 @@
      */
     function action() {
         $objSess = new SC_Session();
-        $objQuery =& SC_Query::getSingletonInstance();
 
         // 認証可否の判定
         SC_Utils_Ex::sfIsSuccess($objSess);
 
-        $cnt = $objQuery->count("dtb_baseinfo");
+        $cnt = $this->lfGetBaseInfoCount();
 
         if ($cnt > 0) {
             $this->tpl_mode = "update";
@@ -122,8 +121,8 @@
             }
         } else {
             $arrCol = $this->lfGetCol();
-            $col	= SC_Utils_Ex::sfGetCommaList($arrCol);
-            $arrRet = $objQuery->select($col, "dtb_baseinfo");
+            $col    = SC_Utils_Ex::sfGetCommaList($arrCol);
+            $arrRet = $this->lfGetBaseInfoData($col);
             $this->arrForm = $arrRet[0];
 
             $regular_holiday_ids = explode('|', $this->arrForm['regular_holiday_ids']);
@@ -141,6 +140,28 @@
         parent::destroy();
     }
 
+    /**
+     * 基本情報の登録数を取得する
+     *
+     * @return int
+     */
+    function lfGetBaseInfoCount() {
+        $objQuery =& SC_Query::getSingletonInstance();
+
+        return $objQuery->count("dtb_baseinfo");
+    }
+
+    /**
+     * 基本情報のデータを取得する
+     *
+     * @return array
+     */
+    function lfGetBaseInfoData($col) {
+        $objQuery =& SC_Query::getSingletonInstance();
+
+        return $objQuery->select($col, "dtb_baseinfo");
+    }
+
     // 基本情報用のカラムを取り出す。
     function lfGetCol() {
         $arrCol = array(

変更: branches/version-2_5-dev/data/class/pages/admin/basis/LC_Page_Admin_Basis_Delivery.php
===================================================================
--- branches/version-2_5-dev/data/class/pages/admin/basis/LC_Page_Admin_Basis_Delivery.php	2011-02-15 07:43:52 UTC (rev 20167)
+++ branches/version-2_5-dev/data/class/pages/admin/basis/LC_Page_Admin_Basis_Delivery.php	2011-02-15 08:31:03 UTC (rev 20168)
@@ -70,7 +70,6 @@
      */
     function action() {
         $objSess = new SC_Session();
-        $objQuery =& SC_Query::getSingletonInstance();
         $objDb = new SC_Helper_DB_Ex();
 
         // 認証可否の判定
@@ -94,12 +93,23 @@
             break;
         }
 
-        // 配送業者一覧の取得
+        $this->arrDelivList = $this->lfGetDelivList();
+    }
+
+    /**
+     * 配送業者一覧の取得
+     *
+     * @return array
+     */
+    function lfGetDelivList() {
+        $objQuery =& SC_Query::getSingletonInstance();
+
         $col = "deliv_id, name, service_name";
         $where = "del_flg = 0";
         $table = "dtb_deliv";
         $objQuery->setOrder("rank DESC");
-        $this->arrDelivList = $objQuery->select($col, $table, $where);
+
+        return $objQuery->select($col, $table, $where);
     }
 
     /**

変更: branches/version-2_5-dev/data/class/pages/admin/basis/LC_Page_Admin_Basis_Holiday.php
===================================================================
--- branches/version-2_5-dev/data/class/pages/admin/basis/LC_Page_Admin_Basis_Holiday.php	2011-02-15 07:43:52 UTC (rev 20167)
+++ branches/version-2_5-dev/data/class/pages/admin/basis/LC_Page_Admin_Basis_Holiday.php	2011-02-15 08:31:03 UTC (rev 20168)
@@ -67,7 +67,6 @@
      */
     function action() {
         $objSess = new SC_Session();
-        $objQuery =& SC_Query::getSingletonInstance();
         $objDb = new SC_Helper_DB_Ex();
 
         $objDate = new SC_Date();
@@ -109,13 +108,13 @@
             break;
         // 編集前処理
         case 'pre_edit':
-            // 編集項目をDBより取得する。
-            $where = "holiday_id = ?";
-            $arrRet = $objQuery->select("title, month, day", "dtb_holiday", $where, array($_POST['holiday_id']));
+            // 編集項目を取得する。
+            $arrHolidayData = $this->lfGetHolidayDataByHolidayID($_POST['holiday_id']);
+
             // 入力項目にカテゴリ名を入力する。
-            $this->arrForm['title'] = $arrRet[0]['title'];
-            $this->arrForm['month'] = $arrRet[0]['month'];
-            $this->arrForm['day'] = $arrRet[0]['day'];
+            $this->arrForm['title'] = $arrHolidayData[0]['title'];
+            $this->arrForm['month'] = $arrHolidayData[0]['month'];
+            $this->arrForm['day'] = $arrHolidayData[0]['day'];
             // POSTデータを引き継ぐ
             $this->tpl_holiday_id = $_POST['holiday_id'];
         break;
@@ -133,10 +132,7 @@
             break;
         }
 
-        // 規格の読込
-        $where = "del_flg <> 1";
-        $objQuery->setOrder("rank DESC");
-        $this->arrHoliday = $objQuery->select("holiday_id, title, month, day", "dtb_holiday", $where);
+        $this->arrHoliday = $this->lfGetHolidayList();
     }
 
     /**
@@ -148,6 +144,21 @@
         parent::destroy();
     }
 
+    function lfGetHolidayDataByHolidayID($holiday_id) {
+        $objQuery =& SC_Query::getSingletonInstance();
+
+        $where = "holiday_id = ?";
+        return $objQuery->select("title, month, day", "dtb_holiday", $where, array($holiday_id));
+    }
+
+    function lfGetHolidayList() {
+        $objQuery =& SC_Query::getSingletonInstance();
+
+        $where = "del_flg <> 1";
+        $objQuery->setOrder("rank DESC");
+        return $objQuery->select("holiday_id, title, month, day", "dtb_holiday", $where);
+    }
+
     /* DBへの挿入 */
     function lfInsertClass($arrData) {
         $objQuery =& SC_Query::getSingletonInstance();

変更: branches/version-2_5-dev/data/class/pages/admin/basis/LC_Page_Admin_Basis_Kiyaku.php
===================================================================
--- branches/version-2_5-dev/data/class/pages/admin/basis/LC_Page_Admin_Basis_Kiyaku.php	2011-02-15 07:43:52 UTC (rev 20167)
+++ branches/version-2_5-dev/data/class/pages/admin/basis/LC_Page_Admin_Basis_Kiyaku.php	2011-02-15 08:31:03 UTC (rev 20168)
@@ -67,7 +67,6 @@
      */
     function action() {
         $objSess = new SC_Session();
-        $objQuery =& SC_Query::getSingletonInstance();
         $objDb = new SC_Helper_DB_Ex();
 
         // 認証可否の判定
@@ -105,12 +104,12 @@
             break;
         // 編集前処理
         case 'pre_edit':
-            // 編集項目をDBより取得する。
-            $where = "kiyaku_id = ?";
-            $arrRet = $objQuery->select("kiyaku_text, kiyaku_title", "dtb_kiyaku", $where, array($_POST['kiyaku_id']));
+            // 編集項目を取得する。
+            $arrKiyakuData = $this->lfGetKiyakuDataByKiyakuID($_POST['kiyaku_id']);
+
             // 入力項目にカテゴリ名を入力する。
-            $this->arrForm['kiyaku_title'] = $arrRet[0]['kiyaku_title'];
-            $this->arrForm['kiyaku_text'] = $arrRet[0]['kiyaku_text'];
+            $this->arrForm['kiyaku_title'] = $arrKiyakuData[0]['kiyaku_title'];
+            $this->arrForm['kiyaku_text'] = $arrKiyakuData[0]['kiyaku_text'];
             // POSTデータを引き継ぐ
             $this->tpl_kiyaku_id = $_POST['kiyaku_id'];
         break;
@@ -128,10 +127,7 @@
             break;
         }
 
-        // 規格の読込
-        $where = "del_flg <> 1";
-        $objQuery->setOrder("rank DESC");
-        $this->arrKiyaku = $objQuery->select("kiyaku_title, kiyaku_text, kiyaku_id", "dtb_kiyaku", $where);
+        $this->arrKiyaku = $this->lfGetKiyakuList();
     }
 
     /**
@@ -159,6 +155,21 @@
         return $ret;
     }
 
+    function lfGetKiyakuDataByKiyakuID($kiyaku_id) {
+        $objQuery =& SC_Query::getSingletonInstance();
+
+        $where = "kiyaku_id = ?";
+        return $objQuery->select("kiyaku_text, kiyaku_title", "dtb_kiyaku", $where, array($kiyaku_id));
+    }
+
+    function lfGetKiyakuList() {
+        $objQuery =& SC_Query::getSingletonInstance();
+
+        $where = "del_flg <> 1";
+        $objQuery->setOrder("rank DESC");
+        return $objQuery->select("kiyaku_title, kiyaku_text, kiyaku_id", "dtb_kiyaku", $where);
+    }
+
     /* DBへの更新 */
     function lfUpdateClass($arrData) {
         $objQuery =& SC_Query::getSingletonInstance();

変更: branches/version-2_5-dev/data/class/pages/admin/basis/LC_Page_Admin_Basis_Mail.php
===================================================================
--- branches/version-2_5-dev/data/class/pages/admin/basis/LC_Page_Admin_Basis_Mail.php	2011-02-15 07:43:52 UTC (rev 20167)
+++ branches/version-2_5-dev/data/class/pages/admin/basis/LC_Page_Admin_Basis_Mail.php	2011-02-15 08:31:03 UTC (rev 20168)
@@ -66,7 +66,7 @@
      * @return void
      */
     function action() {
-        $objQuery =& SC_Query::getSingletonInstance();
+
         $objSess = new SC_Session();
         $masterData = new SC_DB_MasterData_Ex();
 
@@ -80,8 +80,7 @@
             // テンプレートプルダウン変更時
 
             if ( SC_Utils_Ex::sfCheckNumLength( $_POST['template_id']) ){
-                $sql = "SELECT * FROM dtb_mailtemplate WHERE template_id = ?";
-                $result = $objQuery->getAll($sql, array($_POST['template_id']) );
+                $result = $this->lfGetMailTemplateByTemplateID($_POST['template_id']);
                 if ( $result ){
                     $this->arrForm = $result[0];
                 } else {
@@ -102,7 +101,7 @@
 
                 } else {
                     // 正常
-                    $this->lfRegist($objQuery, $this->arrForm);
+                    $this->lfRegist($this->arrForm);
 
                     // 完了メッセージ
                     $this->tpl_onload = "window.alert('メール設定が完了しました。テンプレートを選択して内容をご確認ください。');";
@@ -124,8 +123,16 @@
         parent::destroy();
     }
 
-    function lfRegist(&$objQuery, $data ){
+    function lfGetMailTemplateByTemplateID($template_id) {
+        $objQuery =& SC_Query::getSingletonInstance();
 
+        $sql = "SELECT * FROM dtb_mailtemplate WHERE template_id = ?";
+        return $objQuery->getAll($sql, array($template_id) );
+    }
+
+    function lfRegist($data ){
+        $objQuery =& SC_Query::getSingletonInstance();
+
         $data['creator_id'] = $_SESSION['member_id'];
 
         $sql = "SELECT * FROM dtb_mailtemplate WHERE template_id = ?";

変更: branches/version-2_5-dev/data/class/pages/admin/basis/LC_Page_Admin_Basis_Point.php
===================================================================
--- branches/version-2_5-dev/data/class/pages/admin/basis/LC_Page_Admin_Basis_Point.php	2011-02-15 07:43:52 UTC (rev 20167)
+++ branches/version-2_5-dev/data/class/pages/admin/basis/LC_Page_Admin_Basis_Point.php	2011-02-15 08:31:03 UTC (rev 20168)
@@ -72,7 +72,6 @@
      */
     function action() {
         $objSess = new SC_Session();
-        $objQuery =& SC_Query::getSingletonInstance();
 
         // 認証可否の判定
         SC_Utils_Ex::sfIsSuccess($objSess);
@@ -84,8 +83,7 @@
         // POST値の取得
         $this->objFormParam->setParam($_POST);
 
-        $cnt = $objQuery->count("dtb_baseinfo");
-
+        $cnt = $this->lfGetBaseInfoCount();
         if ($cnt > 0) {
             $this->tpl_mode = "update";
         } else {
@@ -115,8 +113,7 @@
         } else {
             $arrCol = $this->objFormParam->getKeyList(); // キー名一覧を取得
             $col    = SC_Utils_Ex::sfGetCommaList($arrCol);
-            // DB値の取得
-            $arrRet = $objQuery->select($col, "dtb_baseinfo");
+            $arrRet = $this->lfGetBaseInfoData($col);
             $this->objFormParam->setParam($arrRet[0]);
         }
 
@@ -132,6 +129,28 @@
         parent::destroy();
     }
 
+    /**
+     * 基本情報の登録数を取得する
+     *
+     * @return int
+     */
+    function lfGetBaseInfoCount() {
+        $objQuery =& SC_Query::getSingletonInstance();
+
+        return $objQuery->count("dtb_baseinfo");
+    }
+
+    /**
+     * 基本情報のデータを取得する
+     *
+     * @return array
+     */
+    function lfGetBaseInfoData($col) {
+        $objQuery =& SC_Query::getSingletonInstance();
+
+        return $objQuery->select($col, "dtb_baseinfo");
+    }
+
     /* パラメータ情報の初期化 */
     function lfInitParam() {
         $this->objFormParam->addParam("ポイント付与率", "point_rate", PERCENTAGE_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"));

変更: branches/version-2_5-dev/data/class/pages/admin/basis/LC_Page_Admin_Basis_Tradelaw.php
===================================================================
--- branches/version-2_5-dev/data/class/pages/admin/basis/LC_Page_Admin_Basis_Tradelaw.php	2011-02-15 07:43:52 UTC (rev 20167)
+++ branches/version-2_5-dev/data/class/pages/admin/basis/LC_Page_Admin_Basis_Tradelaw.php	2011-02-15 08:31:03 UTC (rev 20168)
@@ -75,7 +75,6 @@
      */
     function action() {
         $objSess = new SC_Session();
-        $objQuery =& SC_Query::getSingletonInstance();
 
         // 認証可否の判定
         SC_Utils_Ex::sfIsSuccess($objSess);
@@ -87,7 +86,7 @@
         // POST値の取得
         $this->objFormParam->setParam($_POST);
 
-        $cnt = $objQuery->count("dtb_baseinfo");
+        $cnt = $this->lfGetBaseInfoCount();
 
         if ($cnt > 0) {
             $this->tpl_mode = "update";
@@ -118,8 +117,7 @@
         } else {
             $arrCol = $this->objFormParam->getKeyList(); // キー名一覧を取得
             $col    = SC_Utils_Ex::sfGetCommaList($arrCol);
-            // DB値の取得
-            $arrRet = $objQuery->select($col, "dtb_baseinfo");
+            $arrRet = $this->lfGetBaseInfoData($col);
             $this->objFormParam->setParam($arrRet[0]);
         }
 
@@ -135,6 +133,28 @@
         parent::destroy();
     }
 
+    /**
+     * 基本情報の登録数を取得する
+     *
+     * @return int
+     */
+    function lfGetBaseInfoCount() {
+        $objQuery =& SC_Query::getSingletonInstance();
+
+        return $objQuery->count("dtb_baseinfo");
+    }
+
+    /**
+     * 基本情報のデータを取得する
+     *
+     * @return array
+     */
+    function lfGetBaseInfoData($col) {
+        $objQuery =& SC_Query::getSingletonInstance();
+
+        return $objQuery->select($col, "dtb_baseinfo");
+    }
+
     /* パラメータ情報の初期化 */
     function lfInitParam() {
         $this->objFormParam->addParam("販売業者", "law_company", STEXT_LEN, "KVa", array("EXIST_CHECK", "MAX_LENGTH_CHECK"));

変更: branches/version-2_5-dev/data/class/pages/admin/basis/LC_Page_Admin_Basis_ZipInstall.php
===================================================================
--- branches/version-2_5-dev/data/class/pages/admin/basis/LC_Page_Admin_Basis_ZipInstall.php	2011-02-15 07:43:52 UTC (rev 20167)
+++ branches/version-2_5-dev/data/class/pages/admin/basis/LC_Page_Admin_Basis_ZipInstall.php	2011-02-15 08:31:03 UTC (rev 20168)
@@ -89,7 +89,6 @@
      * @return void
      */
     function action() {
-        $objQuery =& SC_Query::getSingletonInstance();
 
         SC_Utils_Ex::sfIsSuccess(new SC_Session);
 
@@ -109,10 +108,7 @@
             switch ($this->tpl_mode) {
                 // 自動登録
                 case 'auto':
-                    $objQuery->begin();
-                    $objQuery->delete('mtb_zip');
-                    $this->insertMtbZip();
-                    $objQuery->commit();
+                    $this->lfAutoCommit();
                     break;
                 // 手動登録
                 case 'manual':
@@ -125,7 +121,7 @@
         switch ($this->tpl_mode) {
             // 手動削除
             case 'delete':
-                $objQuery->delete('mtb_zip');
+                $this->lfDeleteZip();
 
                 // 進捗・完了画面を表示しない
                 $this->tpl_mode = null;
@@ -146,6 +142,21 @@
         parent::destroy();
     }
 
+    function lfAutoCommit() {
+        $objQuery =& SC_Query::getSingletonInstance();
+
+        $objQuery->begin();
+        $objQuery->delete('mtb_zip');
+        $this->insertMtbZip();
+        $objQuery->commit();
+    }
+
+    function lfDeleteZip() {
+        $objQuery =& SC_Query::getSingletonInstance();
+
+        $objQuery->delete('mtb_zip');
+    }
+
     /**
      * パラメータ情報の初期化
      *




Svn-src-all メーリングリストの案内