Ignore:
Timestamp:
2012/02/06 21:27:04 (12 years ago)
Author:
Seasoft
Message:

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

  • 無意味なスペースを削除
File:
1 edited

Legend:

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

    r21442 r21444  
    4444 
    4545    //-- SQL分生成 
    46     function getSql( $mode = "" ){ 
     46    function getSql( $mode = ""){ 
    4747        $this->sql = $this->select ." ". $this->where ." ". $this->group ." "; 
    4848 
     
    6868        // ある単位のみ検索($from = $to) 
    6969        if ($from == $to) { 
    70             $this->setWhere( $column ." = ?" ); 
     70            $this->setWhere( $column ." = ?"); 
    7171            $return = array($from); 
    7272        // ~$toまで検索 
     
    8080        // $from~$toの検索 
    8181        } else { 
    82             $this->setWhere( $column ." BETWEEN ? AND ?" ); 
     82            $this->setWhere( $column ." BETWEEN ? AND ?"); 
    8383            $return = array($from, $to); 
    8484        } 
     
    102102 
    103103        // 開始期間だけ指定の場合 
    104         if (( $from_year != "" ) && ( $from_month != "" ) && ( $from_day != "" ) && ( $to_year == "" ) && ( $to_month == "" ) && ( $to_day == "" )) { 
     104        if (( $from_year != "" ) && ( $from_month != "" ) && ( $from_day != "" ) && ( $to_year == "" ) && ( $to_month == "" ) && ( $to_day == "")) { 
    105105            $this->setWhere( $column .' >= ?'); 
    106106            $return[] = $date1; 
     
    108108 
    109109        // 開始~終了 
    110         if( ( $from_year != "" ) && ( $from_month != "" ) && ( $from_day != "" ) && 
    111             ( $to_year != "" ) && ( $to_month != "" ) && ( $to_day != "" ) ) { 
    112             $this->setWhere( $column . ' >= ? AND ' . $column . ' < date(?)' ); 
     110        if( ( $from_year != "" ) && ( $from_month != "" ) && ( $from_day != "") && 
     111            ( $to_year != "" ) && ( $to_month != "" ) && ( $to_day != "" )) { 
     112            $this->setWhere( $column . ' >= ? AND ' . $column . ' < date(?)'); 
    113113            $return[] = $date1; 
    114114            $return[] = $date2; 
     
    116116 
    117117        // 終了期間だけ指定の場合 
    118         if (( $from_year == "" ) && ( $from_month == "" ) && ( $from_day == "" ) && ( $to_year != "" ) && ( $to_month != "" ) && ( $to_day != "" )) { 
     118        if (( $from_year == "" ) && ( $from_month == "" ) && ( $from_day == "" ) && ( $to_year != "" ) && ( $to_month != "" ) && ( $to_day != "")) { 
    119119            $this->setWhere( $column . ' < date(?)'); 
    120120            $return[] = $date2; 
     
    124124    } 
    125125 
    126     // checkboxなどで同一カラム内で単一、もしくは複数選択肢が有る場合 例: AND ( sex = xxx OR sex = xxx OR sex = xxx  ) AND ... 
    127     function setItemTerm( $arr, $ItemStr ) { 
     126    // checkboxなどで同一カラム内で単一、もしくは複数選択肢が有る場合 例: AND ( sex = xxx OR sex = xxx OR sex = xxx) AND ... 
     127    function setItemTerm( $arr, $ItemStr) { 
    128128 
    129129        foreach ($arr as $data) { 
    130130 
    131             if (count( $arr ) > 1) { 
    132                 if( ! is_null( $data ) ) $item .= $ItemStr . " = ? OR "; 
     131            if (count( $arr) > 1) { 
     132                if( ! is_null( $data )) $item .= $ItemStr . " = ? OR "; 
    133133            } else { 
    134                 if( ! is_null( $data ) ) $item = $ItemStr . " = ?"; 
     134                if( ! is_null( $data )) $item = $ItemStr . " = ?"; 
    135135            } 
    136136            $return[] = $data; 
    137137        } 
    138138 
    139         if( count( $arr ) > 1 )  $item = "( " . rtrim( $item, " OR " ) . " )"; 
    140         $this->setWhere( $item ); 
     139        if( count( $arr ) > 1 )  $item = "( " . rtrim( $item, " OR " ) . ")"; 
     140        $this->setWhere( $item); 
    141141        return $return; 
    142142    } 
    143143 
    144144    // NULL値が必要な場合 
    145     function setItemTermWithNull( $arr, $ItemStr ) { 
     145    function setItemTermWithNull( $arr, $ItemStr) { 
    146146 
    147147        $item = " ${ItemStr} IS NULL "; 
     
    156156        } 
    157157 
    158         $item = "( ${item} ) "; 
    159         $this->setWhere( $item ); 
     158        $item = "( ${item}) "; 
     159        $this->setWhere( $item); 
    160160        return $return; 
    161161    } 
    162162    // NULLもしくは''で検索する場合 
    163     function setItemTermWithNullAndSpace( $arr, $ItemStr ) { 
     163    function setItemTermWithNullAndSpace( $arr, $ItemStr) { 
    164164        $count = count($arr); 
    165165        $item = " ${ItemStr} IS NULL OR ${ItemStr} = '' "; 
     
    173173            } 
    174174        } 
    175         $item = "( ${item} ) "; 
    176         $this->setWhere( $item ); 
    177         return $return; 
    178     } 
    179  
    180     /* 複数のカラムでORで優先検索する場合 例: AND ( item_flag1 = xxx OR item_flag2 = xxx OR item_flag3 = xxx  ) AND ... 
     175        $item = "( ${item}) "; 
     176        $this->setWhere( $item); 
     177        return $return; 
     178    } 
     179 
     180    /* 複数のカラムでORで優先検索する場合 例: AND ( item_flag1 = xxx OR item_flag2 = xxx OR item_flag3 = xxx) AND ... 
    181181 
    182182        配列の構造例  
    183         if ( $_POST['show_site1'] ) $arrShowsite_1 = array( 'column' => "show_site1", 
    184                                                             'value'  => $_POST['show_site1'] ); 
     183        if ( $_POST['show_site1']) $arrShowsite_1 = array( 'column' => "show_site1", 
     184                                                            'value'  => $_POST['show_site1']); 
    185185 
    186186    */ 
    187     function setWhereByOR( $arrWhere ){ 
    188  
    189         $count = count( $arrWhere ); 
     187    function setWhereByOR( $arrWhere){ 
     188 
     189        $count = count( $arrWhere); 
    190190 
    191191        for ($i = 0; $i < $count; $i++) { 
    192192 
    193             if( isset( $arrWhere[$i]['value'] ) ) $statement .= $arrWhere[$i]['column'] ." = " . SC_Utils_Ex::sfQuoteSmart($arrWhere[$i]['value']) ." OR "  ; 
    194         } 
    195  
    196         $statement = "( " . rtrim( $statement, " OR " ) . " )"; 
     193            if( isset( $arrWhere[$i]['value'] )) $statement .= $arrWhere[$i]['column'] ." = " . SC_Utils_Ex::sfQuoteSmart($arrWhere[$i]['value']) ." OR "  ; 
     194        } 
     195 
     196        $statement = "( " . rtrim( $statement, " OR " ) . ")"; 
    197197 
    198198        if ($this->where) { 
     
    225225    } 
    226226 
    227     function setGroup( $group ) { 
     227    function setGroup( $group) { 
    228228 
    229229        $this->group =  "GROUP BY " . $group; 
     
    231231    } 
    232232 
    233     function setLimitOffset( $limit, $offset ){ 
     233    function setLimitOffset( $limit, $offset){ 
    234234 
    235235        if (is_numeric($limit) and is_numeric($offset)) { 
Note: See TracChangeset for help on using the changeset viewer.