Ignore:
Timestamp:
2012/02/06 11:05:15 (14 years ago)
Author:
Seasoft
Message:

#1613 (ソース整形・ソースコメントの改善)

  • Zend Framework PHP 標準コーディング規約への準拠を高めた
File:
1 edited

Legend:

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

    r21425 r21441  
    7474 
    7575        // 正常に接続されている場合 
    76         if(!$objQuery->isError()) { 
     76        if (!$objQuery->isError()) { 
    7777            list($db_type) = explode(":", $dsn); 
    7878 
     
    8080            $columns = $objQuery->listTableFields($table_name); 
    8181 
    82             if(in_array($col_name, $columns)){ 
     82            if (in_array($col_name, $columns)) { 
    8383                return true; 
    8484            } 
     
    8686 
    8787        // カラムを追加する 
    88         if($add){ 
     88        if ($add) { 
    8989            $objQuery->query("ALTER TABLE $table_name ADD $col_name $col_type "); 
    9090            return true; 
     
    112112 
    113113        // データを追加する 
    114         if(!$exists && $add) { 
     114        if (!$exists && $add) { 
    115115            $objQuery->exec($sql); 
    116116        } 
     
    175175    function sfGetRootId() { 
    176176 
    177         if(!$this->g_root_on)  { 
     177        if (!$this->g_root_on) { 
    178178            $this->g_root_on = true; 
    179179            $objQuery =& SC_Query_Ex::getSingletonInstance(); 
     
    182182            if (!isset($_GET['category_id'])) $_GET['category_id'] = ""; 
    183183 
    184             if(!empty($_GET['product_id']) || !empty($_GET['category_id'])) { 
     184            if (!empty($_GET['product_id']) || !empty($_GET['category_id'])) { 
    185185                // 選択中のカテゴリIDを判定する 
    186186                $category_id = $this->sfGetCategoryId($_GET['product_id'], $_GET['category_id']); 
    187187                // ROOTカテゴリIDの取得 
    188                 if(count($category_id) > 0) { 
     188                if (count($category_id) > 0) { 
    189189                    $arrRet = $this->sfGetParents('dtb_category', 'parent_category_id', 'category_id', $category_id); 
    190190                    $root_id = isset($arrRet[0]) ? $arrRet[0] : ""; 
     
    214214        $arrRet = $objQuery->select("customer_id", "dtb_order", "order_id = ?", array($order_id)); 
    215215        $customer_id = $arrRet[0]['customer_id']; 
    216         if($customer_id != "" && $customer_id >= 1) { 
     216        if ($customer_id != "" && $customer_id >= 1) { 
    217217            $arrRet = $objQuery->select('point', "dtb_customer", "customer_id = ?", array($customer_id)); 
    218218            $point = $arrRet[0]['point']; 
     
    257257        $from = "dtb_category as cat left join dtb_category_total_count as ttl on ttl.category_id = cat.category_id"; 
    258258        // 登録商品数のチェック 
    259         if($count_check) { 
     259        if ($count_check) { 
    260260            $where = "del_flg = 0 AND product_count > 0"; 
    261261        } else { 
     
    267267        $arrParentID = SC_Helper_DB_Ex::sfGetParents('dtb_category', 'parent_category_id', 'category_id', $parent_category_id); 
    268268 
    269         foreach($arrRet as $key => $array) { 
    270             foreach($arrParentID as $val) { 
    271                 if($array['category_id'] == $val) { 
     269        foreach ($arrRet as $key => $array) { 
     270            foreach ($arrParentID as $val) { 
     271                if ($array['category_id'] == $val) { 
    272272                    $arrRet[$key]['display'] = 1; 
    273273                    break; 
     
    325325        $from = "dtb_category as cat left join dtb_category_total_count as ttl on ttl.category_id = cat.category_id"; 
    326326        // 登録商品数のチェック 
    327         if($count_check) { 
     327        if ($count_check) { 
    328328            $where = "del_flg = 0 AND product_count > 0"; 
    329329        } else { 
     
    339339            $arrParentID = SC_Helper_DB_Ex::sfGetParents('dtb_category', 'parent_category_id', 'category_id', $parent_category_id); 
    340340 
    341             foreach($arrParentID as $pid) { 
    342                 foreach($arrRet as $key => $array) { 
    343                     if($array['category_id'] == $pid) { 
     341            foreach ($arrParentID as $pid) { 
     342                foreach ($arrRet as $key => $array) { 
     343                    if ($array['category_id'] == $pid) { 
    344344                        $arrCatTree[$pkey][] = $arrRet[$key]; 
    345345                        break; 
     
    365365 
    366366        // カテゴリ名称を取得する 
    367         foreach($arrCatID as $key => $val){ 
     367        foreach ($arrCatID as $key => $val) { 
    368368            $sql = "SELECT category_name FROM dtb_category WHERE category_id = ?"; 
    369369            $arrVal = array($val); 
     
    428428        $where = "del_flg = 0"; 
    429429 
    430         if($addwhere != "") { 
     430        if ($addwhere != "") { 
    431431            $where.= " AND $addwhere"; 
    432432        } 
     
    434434        $objQuery->setOption("ORDER BY rank DESC"); 
    435435 
    436         if($products_check) { 
     436        if ($products_check) { 
    437437            $col = "T1.category_id, category_name, level"; 
    438438            $from = "dtb_category AS T1 LEFT JOIN dtb_category_total_count AS T2 ON T1.category_id = T2.category_id"; 
     
    446446 
    447447        $max = count($arrRet); 
    448         for($cnt = 0; $cnt < $max; $cnt++) { 
     448        for ($cnt = 0; $cnt < $max; $cnt++) { 
    449449            $id = $arrRet[$cnt]['category_id']; 
    450450            $name = $arrRet[$cnt]['category_name']; 
     
    484484        $max = count($arrRet); 
    485485 
    486         for($cnt = 0; $cnt < $max; $cnt++) { 
    487             if($parent_zero) { 
    488                 if($arrRet[$cnt]['level'] == LEVEL_MAX) { 
     486        for ($cnt = 0; $cnt < $max; $cnt++) { 
     487            if ($parent_zero) { 
     488                if ($arrRet[$cnt]['level'] == LEVEL_MAX) { 
    489489                    $arrValue[$cnt] = $arrRet[$cnt]['category_id']; 
    490490                } else { 
     
    651651        $objProduct = new SC_Product_Ex(); 
    652652 
    653         if($objQuery == NULL) { 
     653        if ($objQuery == NULL) { 
    654654            $objQuery =& SC_Query_Ex::getSingletonInstance(); 
    655655        } 
    656656 
    657657        $is_out_trans = false; 
    658         if(!$objQuery->inTransaction()){ 
     658        if (!$objQuery->inTransaction()) { 
    659659            $objQuery->begin(); 
    660660            $is_out_trans = true; 
     
    667667            $where_products_class = '(stock >= 1 OR stock_unlimited = 1)'; 
    668668            $from = $objProduct->alldtlSQL($where_products_class); 
    669         }else{ 
     669        } else { 
    670670            $from = 'dtb_products as alldtl'; 
    671671        } 
     
    675675 
    676676        //まずテーブル内容の元を取得 
    677         if(!$is_force_all_count) { 
     677        if (!$is_force_all_count) { 
    678678            $arrCategoryCountOld = $objQuery->select('category_id,product_count','dtb_category_count'); 
    679         }else{ 
     679        } else { 
    680680            $arrCategoryCountOld = array(); 
    681681        } 
     
    700700        //古いデータの構造入れ替え 
    701701        $arrOld = array(); 
    702         foreach($arrCategoryCountOld as $item){ 
     702        foreach ($arrCategoryCountOld as $item) { 
    703703            $arrOld[$item['category_id']] = $item['product_count']; 
    704704        } 
    705705        //新しいデータの構造入れ替え 
    706706        $arrNew = array(); 
    707         foreach($arrCategoryCountNew as $item){ 
     707        foreach ($arrCategoryCountNew as $item) { 
    708708            $arrNew[$item['category_id']] = $item['product_count']; 
    709709        } 
     
    711711        $arrDiffCategory_id = array(); 
    712712        //新しいカテゴリ一覧から見て商品数が異なるデータが無いか確認 
    713         foreach($arrNew as $cid => $count){ 
    714             if($arrOld[$cid] != $count){ 
     713        foreach ($arrNew as $cid => $count) { 
     714            if ($arrOld[$cid] != $count) { 
    715715                $arrDiffCategory_id[] = $cid; 
    716716            } 
    717717        } 
    718718        //削除カテゴリを想定して、古いカテゴリ一覧から見て商品数が異なるデータが無いか確認。 
    719         foreach($arrOld as $cid => $count){ 
    720             if($arrNew[$cid] != $count && $count > 0){ 
     719        foreach ($arrOld as $cid => $count) { 
     720            if ($arrNew[$cid] != $count && $count > 0) { 
    721721                $arrDiffCategory_id[] = $cid; 
    722722            } 
     
    724724 
    725725        //対象IDが無ければ終了 
    726         if(count($arrDiffCategory_id) == 0){ 
    727             if($is_out_trans) { 
     726        if (count($arrDiffCategory_id) == 0) { 
     727            if ($is_out_trans) { 
    728728                $objQuery->commit(); 
    729729            } 
     
    735735 
    736736        //dtb_category_countの更新 差分のあったカテゴリだけ更新する。 
    737         foreach($arrDiffCategory_id as $cid) { 
     737        foreach ($arrDiffCategory_id as $cid) { 
    738738            $sqlval = array(); 
    739739            $sqlval['create_date'] = 'CURRENT_TIMESTAMP'; 
    740740            $sqlval['product_count'] = (string)$arrNew[$cid]; 
    741             if($sqlval['product_count'] =="") { 
     741            if ($sqlval['product_count'] =="") { 
    742742                $sqlval['product_count'] = (string)'0'; 
    743743            } 
    744             if(isset($arrOld[$cid])) { 
     744            if (isset($arrOld[$cid])) { 
    745745                $objQuery->update('dtb_category_count', $sqlval, 'category_id = ?', array($cid)); 
    746             }else{ 
     746            } else { 
    747747                if ($is_force_all_count) { 
    748748                    $ret = $objQuery->update('dtb_category_count', $sqlval, 'category_id = ?', array($cid)); 
     
    791791        } 
    792792        // 更新対象だけを更新。 
    793         foreach($arrUpdateData as $cid => $count) { 
     793        foreach ($arrUpdateData as $cid => $count) { 
    794794            $sqlval = array(); 
    795795            $sqlval['create_date'] = 'CURRENT_TIMESTAMP'; 
    796796            $sqlval['product_count'] = $count; 
    797             if($sqlval['product_count'] =="") { 
     797            if ($sqlval['product_count'] =="") { 
    798798                $sqlval['product_count'] = (string)'0'; 
    799799            } 
    800800            $ret = $objQuery->update('dtb_category_total_count', $sqlval, 'category_id = ?', array($cid)); 
    801             if(!$ret) { 
     801            if (!$ret) { 
    802802                $sqlval['category_id'] = $cid; 
    803803                $ret = $objQuery->insert('dtb_category_total_count', $sqlval); 
     
    805805        } 
    806806        // トランザクション終了処理 
    807         if($is_out_trans) { 
     807        if ($is_out_trans) { 
    808808            $objQuery->commit(); 
    809809        } 
     
    837837        $arrRet = array($id); 
    838838 
    839         while(count($arrRet) > 0) { 
     839        while (count($arrRet) > 0) { 
    840840            $arrChildren = array_merge($arrChildren, $arrRet); 
    841841            $arrRet = SC_Helper_DB_Ex::sfGetChildrenArraySub($table, $pid_name, $id_name, $arrRet); 
     
    897897        $ret = $id; 
    898898 
    899         while($ret != "0" && !SC_Utils_Ex::isBlank($ret)) { 
     899        while ($ret != "0" && !SC_Utils_Ex::isBlank($ret)) { 
    900900            $arrParents[] = $ret; 
    901901            $ret = SC_Helper_DB_Ex::sfGetParentsArraySub($table, $pid_name, $id_name, $ret); 
     
    909909    /* 子ID所属する親IDを取得する */ 
    910910    function sfGetParentsArraySub($table, $pid_name, $id_name, $child) { 
    911         if(SC_Utils_Ex::isBlank($child)) { 
     911        if (SC_Utils_Ex::isBlank($child)) { 
    912912            return false; 
    913913        } 
    914914        $objQuery =& SC_Query_Ex::getSingletonInstance(); 
    915         if(!is_array($child)) { 
     915        if (!is_array($child)) { 
    916916            $child = array($child); 
    917917        } 
     
    952952        $arrList = $objQuery->select($col, $table, $where, $arrVal); 
    953953        $count = count($arrList); 
    954         for($cnt = 0; $cnt < $count; $cnt++) { 
     954        for ($cnt = 0; $cnt < $count; $cnt++) { 
    955955            $key = $arrList[$cnt][$keyname]; 
    956956            $val = $arrList[$cnt][$valname]; 
     
    973973        $objQuery->begin(); 
    974974        $where = "$colname = ?"; 
    975         if($andwhere != "") { 
     975        if ($andwhere != "") { 
    976976            $where.= " AND $andwhere"; 
    977977        } 
     
    981981        $maxrank = $objQuery->max('rank', $table, $andwhere); 
    982982        // ランクが最大値よりも小さい場合に実行する。 
    983         if($rank < $maxrank) { 
     983        if ($rank < $maxrank) { 
    984984            // ランクが一つ上のIDを取得する。 
    985985            $where = "rank = ?"; 
    986             if($andwhere != "") { 
     986            if ($andwhere != "") { 
    987987                $where.= " AND $andwhere"; 
    988988            } 
     
    991991            // ランク入れ替えの実行 
    992992            $sqlup = "UPDATE $table SET rank = ? WHERE $colname = ?"; 
    993             if($andwhere != "") { 
     993            if ($andwhere != "") { 
    994994                $sqlup.= " AND $andwhere"; 
    995995            } 
     
    10131013        $objQuery->begin(); 
    10141014        $where = "$colname = ?"; 
    1015         if($andwhere != "") { 
     1015        if ($andwhere != "") { 
    10161016            $where.= " AND $andwhere"; 
    10171017        } 
     
    10201020 
    10211021        // ランクが1(最小値)よりも大きい場合に実行する。 
    1022         if($rank > 1) { 
     1022        if ($rank > 1) { 
    10231023            // ランクが一つ下のIDを取得する。 
    10241024            $where = "rank = ?"; 
    1025             if($andwhere != "") { 
     1025            if ($andwhere != "") { 
    10261026                $where.= " AND $andwhere"; 
    10271027            } 
     
    10301030            // ランク入れ替えの実行 
    10311031            $sqlup = "UPDATE $table SET rank = ? WHERE $colname = ?"; 
    1032             if($andwhere != "") { 
     1032            if ($andwhere != "") { 
    10331033                $sqlup.= " AND $andwhere"; 
    10341034            } 
     
    10541054 
    10551055        // 自身のランクを取得する 
    1056         if($where != "") { 
     1056        if ($where != "") { 
    10571057            $getWhere = "$keyIdColumn = ? AND " . $where; 
    10581058        } else { 
     
    10641064 
    10651065        // 値の調整(逆順) 
    1066         if($pos > $max) { 
     1066        if ($pos > $max) { 
    10671067            $position = 1; 
    1068         } else if($pos < 1) { 
     1068        } else if ($pos < 1) { 
    10691069            $position = $max; 
    10701070        } else { 
     
    10831083        // 指定した順位の商品から移動させる商品までのrankを1つずらす 
    10841084        $sql = "UPDATE $tableName SET rank = $term WHERE rank BETWEEN ? AND ?"; 
    1085         if($where != "") { 
     1085        if ($where != "") { 
    10861086            $sql.= " AND $where"; 
    10871087        } 
     
    10921092        // 指定した順位へrankを書き換える。 
    10931093        $sql  = "UPDATE $tableName SET rank = ? WHERE $keyIdColumn = ? "; 
    1094         if($where != "") { 
     1094        if ($where != "") { 
    10951095            $sql.= " AND $where"; 
    10961096        } 
     
    11191119        // 削除レコードのランクを取得する。 
    11201120        $where = "$colname = ?"; 
    1121         if($andwhere != "") { 
     1121        if ($andwhere != "") { 
    11221122            $where.= " AND $andwhere"; 
    11231123        } 
    11241124        $rank = $objQuery->get('rank', $table, $where, array($id)); 
    11251125 
    1126         if(!$delete) { 
     1126        if (!$delete) { 
    11271127            // ランクを最下位にする、DELフラグON 
    11281128            $sqlup = "UPDATE $table SET rank = 0, del_flg = 1 "; 
     
    11361136        // 追加レコードのランクより上のレコードを一つずらす。 
    11371137        $where = "rank > ?"; 
    1138         if($andwhere != "") { 
     1138        if ($andwhere != "") { 
    11391139            $where.= " AND $andwhere"; 
    11401140        } 
     
    11591159        $where = ""; 
    11601160 
    1161         for($cnt = 0; $cnt < $len; $cnt++) { 
    1162             if($where == "") { 
     1161        for ($cnt = 0; $cnt < $len; $cnt++) { 
     1162            if ($where == "") { 
    11631163                $where = "$id_name = ?"; 
    11641164            } else { 
     
    12491249        $where = "del_flg = 0"; 
    12501250 
    1251         if($addwhere != "") { 
     1251        if ($addwhere != "") { 
    12521252            $where.= " AND $addwhere"; 
    12531253        } 
    12541254 
    1255         foreach($arrCol as $val) { 
    1256             if($val != "") { 
    1257                 if($where == "") { 
     1255        foreach ($arrCol as $val) { 
     1256            if ($val != "") { 
     1257                if ($where == "") { 
    12581258                    $where = "$val = ?"; 
    12591259                } else { 
     
    12641264        $ret = $objQuery->get($col, $table, $where, $arrval); 
    12651265 
    1266         if($ret != "") { 
     1266        if ($ret != "") { 
    12671267            return true; 
    12681268        } 
     
    13391339        $where = "del_flg = 0"; 
    13401340 
    1341         if($addwhere != "") { 
     1341        if ($addwhere != "") { 
    13421342            $where.= " AND $addwhere"; 
    13431343        } 
     
    13451345        $objQuery->setOption("ORDER BY rank DESC"); 
    13461346 
    1347         if($products_check) { 
     1347        if ($products_check) { 
    13481348            $col = "T1.maker_id, name"; 
    13491349            $from = "dtb_maker AS T1 LEFT JOIN dtb_maker_count AS T2 ON T1.maker_id = T2.maker_id"; 
     
    13571357 
    13581358        $max = count($arrRet); 
    1359         for($cnt = 0; $cnt < $max; $cnt++) { 
     1359        for ($cnt = 0; $cnt < $max; $cnt++) { 
    13601360            $id = $arrRet[$cnt]['maker_id']; 
    13611361            $name = $arrRet[$cnt]['name']; 
Note: See TracChangeset for help on using the changeset viewer.