Ignore:
Timestamp:
2007/09/01 19:22:34 (17 years ago)
Author:
nanasess
Message:

リファクタリング

  • DB 関連の関数を移動
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/feature-module-update/data/class/util/SC_Utils.php

    r15544 r15548  
    734734        $ret = ereg_replace("[  \n\r]*$", "", $ret); 
    735735        return $ret; 
    736     } 
    737  
    738     /* 親IDの配列を元に特定のカラムを取得する。*/ 
    739     function sfGetParentsCol($objQuery, $table, $id_name, $col_name, $arrId ) { 
    740         $col = $col_name; 
    741         $len = count($arrId); 
    742         $where = ""; 
    743  
    744         for($cnt = 0; $cnt < $len; $cnt++) { 
    745             if($where == "") { 
    746                 $where = "$id_name = ?"; 
    747             } else { 
    748                 $where.= " OR $id_name = ?"; 
    749             } 
    750         } 
    751  
    752         $objQuery->setorder("level"); 
    753         $arrRet = $objQuery->select($col, $table, $where, $arrId); 
    754         return $arrRet; 
    755     } 
    756  
    757     /* カテゴリ変更時の移動処理 */ 
    758     function sfMoveCatRank($objQuery, $table, $id_name, $cat_name, $old_catid, $new_catid, $id) { 
    759         if ($old_catid == $new_catid) { 
    760             return; 
    761         } 
    762         // 旧カテゴリでのランク削除処理 
    763         // 移動レコードのランクを取得する。 
    764         $where = "$id_name = ?"; 
    765         $rank = $objQuery->get($table, "rank", $where, array($id)); 
    766         // 削除レコードのランクより上のレコードを一つ下にずらす。 
    767         $where = "rank > ? AND $cat_name = ?"; 
    768         $sqlup = "UPDATE $table SET rank = (rank - 1) WHERE $where"; 
    769         $objQuery->exec($sqlup, array($rank, $old_catid)); 
    770         // 新カテゴリでの登録処理 
    771         // 新カテゴリの最大ランクを取得する。 
    772         $max_rank = $objQuery->max($table, "rank", "$cat_name = ?", array($new_catid)) + 1; 
    773         $where = "$id_name = ?"; 
    774         $sqlup = "UPDATE $table SET rank = ? WHERE $where"; 
    775         $objQuery->exec($sqlup, array($max_rank, $id)); 
    776736    } 
    777737 
Note: See TracChangeset for help on using the changeset viewer.