Ignore:
Timestamp:
2012/08/30 14:15:56 (12 years ago)
Author:
shutta
Message:

refs #1925 (SC_Queryのupdateメソッドの使用を推奨)
SC_Queryのupdateメソッドを使用するように書き換えた。

Location:
branches/version-2_12-dev/data/class
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2_12-dev/data/class/helper/SC_Helper_DB.php

    r21927 r22012  
    985985            $uprank = $rank + 1; 
    986986            $up_id = $objQuery->get($colname, $table, $where, array($uprank)); 
     987 
    987988            // ランク入れ替えの実行 
    988             $sqlup = "UPDATE $table SET rank = ? WHERE $colname = ?"; 
     989            $where = "$colname = ?"; 
    989990            if ($andwhere != '') { 
    990                 $sqlup.= " AND $andwhere"; 
    991             } 
    992             $objQuery->exec($sqlup, array($rank + 1, $id)); 
    993             $objQuery->exec($sqlup, array($rank, $up_id)); 
     991                $where .= " AND $andwhere"; 
     992            } 
     993 
     994            $sqlval = array( 
     995                'rank' => $rank + 1, 
     996            ); 
     997            $arrWhereVal = array($id); 
     998            $objQuery->update($table, $sqlval, $where, $arrWhereVal); 
     999 
     1000            $sqlval = array( 
     1001                'rank' => $rank, 
     1002            ); 
     1003            $arrWhereVal = array($up_id); 
     1004            $objQuery->update($table, $sqlval, $where, $arrWhereVal); 
    9941005        } 
    9951006        $objQuery->commit(); 
     
    10241035            $downrank = $rank - 1; 
    10251036            $down_id = $objQuery->get($colname, $table, $where, array($downrank)); 
     1037 
    10261038            // ランク入れ替えの実行 
    1027             $sqlup = "UPDATE $table SET rank = ? WHERE $colname = ?"; 
     1039            $where = "$colname = ?"; 
    10281040            if ($andwhere != '') { 
    1029                 $sqlup.= " AND $andwhere"; 
    1030             } 
    1031             $objQuery->exec($sqlup, array($rank - 1, $id)); 
    1032             $objQuery->exec($sqlup, array($rank, $down_id)); 
     1041                $where .= " AND $andwhere"; 
     1042            } 
     1043 
     1044            $sqlval = array( 
     1045                'rank' => $rank - 1, 
     1046            ); 
     1047            $arrWhereVal = array($id); 
     1048            $objQuery->update($table, $sqlval, $where, $arrWhereVal); 
     1049 
     1050            $sqlval = array( 
     1051                'rank' => $rank, 
     1052            ); 
     1053            $arrWhereVal = array($down_id); 
     1054            $objQuery->update($table, $sqlval, $where, $arrWhereVal); 
    10331055        } 
    10341056        $objQuery->commit(); 
     
    10781100 
    10791101        // 指定した順位の商品から移動させる商品までのrankを1つずらす 
    1080         $sql = "UPDATE $tableName SET rank = $term WHERE rank BETWEEN ? AND ?"; 
     1102        $sqlval = array(); 
     1103        $arrRawSql = array( 
     1104            'rank' => $term, 
     1105        ); 
     1106        $str_where = 'rank BETWEEN ? AND ?'; 
    10811107        if ($where != '') { 
    1082             $sql.= " AND $where"; 
    1083         } 
    1084  
    1085         if ($position > $rank) $objQuery->exec($sql, array($rank + 1, $position)); 
    1086         if ($position < $rank) $objQuery->exec($sql, array($position, $rank - 1)); 
     1108            $str_where .= " AND $where"; 
     1109        } 
     1110 
     1111        if ($position > $rank) { 
     1112            $arrWhereVal = array($rank + 1, $position); 
     1113            $objQuery->update($tableName, $sqlval, $str_where, $arrWhereVal, $arrRawSql); 
     1114        } 
     1115        if ($position < $rank) { 
     1116            $arrWhereVal = array($position, $rank - 1); 
     1117            $objQuery->update($tableName, $sqlval, $str_where, $arrWhereVal, $arrRawSql); 
     1118        } 
    10871119 
    10881120        // 指定した順位へrankを書き換える。 
    1089         $sql  = "UPDATE $tableName SET rank = ? WHERE $keyIdColumn = ? "; 
     1121        $sqlval = array( 
     1122            'rank' => $position, 
     1123        ); 
     1124        $str_where = "$keyIdColumn = ?"; 
    10901125        if ($where != '') { 
    1091             $sql.= " AND $where"; 
    1092         } 
    1093  
    1094         $objQuery->exec($sql, array($position, $keyId)); 
     1126            $str_where .= " AND $where"; 
     1127        } 
     1128        $arrWhereVal = array($keyId); 
     1129        $objQuery->update($tableName, $sqlval, $str_where, $arrWhereVal); 
     1130 
    10951131        $objQuery->commit(); 
    10961132    } 
     
    11221158        if (!$delete) { 
    11231159            // ランクを最下位にする、DELフラグON 
    1124             $sqlup = "UPDATE $table SET rank = 0, del_flg = 1 "; 
    1125             $sqlup.= "WHERE $colname = ?"; 
    1126             // UPDATEの実行 
    1127             $objQuery->exec($sqlup, array($id)); 
     1160            $sqlval = array( 
     1161                'rank'      => 0, 
     1162                'del_flg'   => 1, 
     1163            ); 
     1164            $where = "$colname = ?"; 
     1165            $arrWhereVal = array($id); 
     1166            $objQuery->update($table, $sqlval, $where, $arrWhereVal); 
    11281167        } else { 
    11291168            $objQuery->delete($table, "$colname = ?", array($id)); 
     
    11311170 
    11321171        // 追加レコードのランクより上のレコードを一つずらす。 
     1172        $sqlval = array(); 
    11331173        $where = 'rank > ?'; 
    11341174        if ($andwhere != '') { 
    1135             $where.= " AND $andwhere"; 
    1136         } 
    1137         $sqlup = "UPDATE $table SET rank = (rank - 1) WHERE $where"; 
    1138         $objQuery->exec($sqlup, array($rank)); 
     1175            $where .= " AND $andwhere"; 
     1176        } 
     1177        $arrWhereVal = array($rank); 
     1178        $arrRawSql = array( 
     1179            'rank' => '(rank - 1)', 
     1180        ); 
     1181        $objQuery->update($table, $sqlval, $where, $arrWhereVal, $arrRawSql); 
     1182 
    11391183        $objQuery->commit(); 
    11401184    } 
     
    11701214    /** 
    11711215     * カテゴリ変更時の移動処理を行う. 
     1216     *  
     1217     * ※この関数って、どこからも呼ばれていないのでは?? 
    11721218     * 
    11731219     * @param SC_Query $objQuery SC_Query インスタンス 
     
    11861232        // 旧カテゴリでのランク削除処理 
    11871233        // 移動レコードのランクを取得する。 
     1234        $sqlval = array(); 
    11881235        $where = "$id_name = ?"; 
    11891236        $rank = $objQuery->get('rank', $table, $where, array($id)); 
    11901237        // 削除レコードのランクより上のレコードを一つ下にずらす。 
    11911238        $where = "rank > ? AND $cat_name = ?"; 
    1192         $sqlup = "UPDATE $table SET rank = (rank - 1) WHERE $where"; 
    1193         $objQuery->exec($sqlup, array($rank, $old_catid)); 
     1239        $arrWhereVal = array($rank, $old_catid); 
     1240        $arrRawSql = array( 
     1241            'rank' => '(rank - 1)', 
     1242        ); 
     1243        $objQuery->update($table, $sqlval, $where, $arrWhereVal, $arrRawSql); 
     1244 
    11941245        // 新カテゴリでの登録処理 
    11951246        // 新カテゴリの最大ランクを取得する。 
    11961247        $max_rank = $objQuery->max('rank', $table, "$cat_name = ?", array($new_catid)) + 1; 
     1248        $sqlval = array( 
     1249            'rank' => $max_rank, 
     1250        ); 
    11971251        $where = "$id_name = ?"; 
    1198         $sqlup = "UPDATE $table SET rank = ? WHERE $where"; 
    1199         $objQuery->exec($sqlup, array($max_rank, $id)); 
     1252        $arrWhereVal = array($id); 
     1253        $objQuery->update($table, $sqlval, $where, $arrWhereVal); 
    12001254    } 
    12011255 
  • branches/version-2_12-dev/data/class/pages/admin/basis/LC_Page_Admin_Basis_Seo.php

    r21867 r22012  
    144144    function lfUpdPageData($arrUpdData = array()) { 
    145145        $objQuery =& SC_Query_Ex::getSingletonInstance(); 
    146         $sql = ''; 
    147  
    148         // SQL生成 
    149         $sql .= ' UPDATE '; 
    150         $sql .= '     dtb_pagelayout '; 
    151         $sql .= ' SET '; 
    152         $sql .= '     author = ? , '; 
    153         $sql .= '     description = ? , '; 
    154         $sql .= '     keyword = ? '; 
    155         $sql .= ' WHERE '; 
    156         $sql .= '     device_type_id = ? '; 
    157         $sql .= '     AND page_id = ? '; 
    158         $sql .= ' '; 
    159  
    160         // SQL実行 
    161         $ret = $objQuery->query($sql, $arrUpdData); 
    162  
    163         return $ret; 
     146 
     147        $table = 'dtb_pagelayout'; 
     148        $sqlval = array( 
     149            'author'        => $arrUpdData[0], 
     150            'description'   => $arrUpdData[1], 
     151            'keyword'       => $arrUpdData[2], 
     152        ); 
     153        $where = 'device_type_id = ? AND page_id = ?'; 
     154        $arrWhereVal = array( 
     155            $arrUpdData[3], 
     156            $arrUpdData[4], 
     157        ); 
     158 
     159        return $objQuery->update($table, $sqlval, $where, $arrWhereVal); 
    164160    } 
    165161 
  • branches/version-2_12-dev/data/class/pages/admin/products/LC_Page_Admin_Products_Category.php

    r21867 r22012  
    469469            $rank = $objQuery->get('rank', 'dtb_category', $where, array($parent_category_id)); 
    470470            // 追加レコードのランク以上のレコードを一つあげる。 
    471             $sqlup = 'UPDATE dtb_category SET rank = (rank + 1) WHERE rank >= ?'; 
    472             $objQuery->exec($sqlup, array($rank)); 
     471            $where = 'rank >= ?'; 
     472            $arrRawSql = array( 
     473                'rank' => '(rank + 1)', 
     474            ); 
     475            $objQuery->update('dtb_category', array(), $where, array($rank), $arrRawSql); 
    473476        } 
    474477 
     
    564567        $arrRet = $objDb->sfGetChildrenArray($table, $pid_name, $id_name, $id); 
    565568        $line = SC_Utils_Ex::sfGetCommaList($arrRet); 
    566         $sql = "UPDATE $table SET rank = (rank + $count) WHERE $id_name IN ($line) "; 
    567         $sql.= 'AND del_flg = 0'; 
    568         $ret = $objQuery->exec($sql); 
    569         return $ret; 
     569        $where = "$id_name IN ($line) AND del_flg = 0"; 
     570        $arrRawVal = array( 
     571            'rank' => "(rank + $count)", 
     572        ); 
     573        return $objQuery->update($table, array(), $where, array(), $arrRawVal); 
    570574    } 
    571575 
     
    575579        $arrRet = $objDb->sfGetChildrenArray($table, $pid_name, $id_name, $id); 
    576580        $line = SC_Utils_Ex::sfGetCommaList($arrRet); 
    577         $sql = "UPDATE $table SET rank = (rank - $count) WHERE $id_name IN ($line) "; 
    578         $sql.= 'AND del_flg = 0'; 
    579         $ret = $objQuery->exec($sql); 
    580         return $ret; 
     581        $where = "$id_name IN ($line) AND del_flg = 0"; 
     582        $arrRawVal = array( 
     583            'rank' => "(rank - $count)", 
     584        ); 
     585        return $objQuery->update($table, array(), $where, array(), $arrRawVal); 
    581586    } 
    582587} 
  • branches/version-2_12-dev/data/class/pages/admin/products/LC_Page_Admin_Products_UploadCSVCategory.php

    r21867 r22012  
    528528            $rank = $objQuery->get('rank', 'dtb_category', $where, array($parent_category_id)); 
    529529            // 追加レコードのランク以上のレコードを一つあげる。 
    530             $sqlup = 'UPDATE dtb_category SET rank = (rank + 1) WHERE rank >= ?'; 
    531             $objQuery->exec($sqlup, array($rank)); 
     530            $where = 'rank >= ?'; 
     531            $arrRawSql = array( 
     532                'rank' => '(rank + 1)', 
     533            ); 
     534            $objQuery->update('dtb_category', array(), $where, array($rank), $arrRawSql); 
    532535        } 
    533536 
Note: See TracChangeset for help on using the changeset viewer.