Ignore:
Timestamp:
2012/02/15 19:56:17 (12 years ago)
Author:
Seasoft
Message:

#1625 (typo修正・ソース整形・ソースコメントの改善)

File:
1 edited

Legend:

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

    r21481 r21514  
    3737 
    3838    //-- コンストラクタ。 
    39     function SC_SelectSql($array = "") { 
     39    function SC_SelectSql($array = '') { 
    4040        if (is_array($array)) { 
    4141            $this->arrSql = $array; 
     
    4444 
    4545    //-- SQL分生成 
    46     function getSql($mode = "") { 
    47         $this->sql = $this->select ." ". $this->where ." ". $this->group ." "; 
     46    function getSql($mode = '') { 
     47        $this->sql = $this->select .' '. $this->where .' '. $this->group ." "; 
    4848 
    4949        // $mode == 1 は limit & offset無し 
     
    5151            $this->sql .= $this->order; 
    5252        } elseif ($mode != 1) { 
    53             $this->sql .= $this->order . " " .$this->limit ." ". $this->offset; 
     53            $this->sql .= $this->order . ' ' .$this->limit .' '. $this->offset; 
    5454        } 
    5555 
     
    5959        // 検索用 
    6060    function addSearchStr($val) { 
    61         $return = "%" .$val. "%"; 
     61        $return = '%' .$val. '%'; 
    6262        return $return; 
    6363    } 
     
    6868        // ある単位のみ検索($from = $to) 
    6969        if ($from == $to) { 
    70             $this->setWhere($column ." = ?"); 
     70            $this->setWhere($column .' = ?'); 
    7171            $return = array($from); 
    7272        // ~$toまで検索 
    7373        } elseif (strlen($from) == 0 && strlen($to) > 0) { 
    74             $this->setWhere($column ." <= ? "); 
     74            $this->setWhere($column .' <= ? '); 
    7575            $return = array($to); 
    7676        // ~$from以上を検索 
    7777        } elseif (strlen($from) > 0 && strlen($to) == 0) { 
    78             $this->setWhere($column ." >= ? "); 
     78            $this->setWhere($column .' >= ? '); 
    7979            $return = array($from); 
    8080        // $from~$toの検索 
    8181        } else { 
    82             $this->setWhere($column ." BETWEEN ? AND ?"); 
     82            $this->setWhere($column .' BETWEEN ? AND ?'); 
    8383            $return = array($from, $to); 
    8484        } 
     
    9191 
    9292        // 開始期間の構築 
    93         $date1 = $from_year . "/" . $from_month . "/" . $from_day; 
     93        $date1 = $from_year . '/' . $from_month . '/' . $from_day; 
    9494 
    9595        // 終了期間の構築 
     
    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 != "")) { 
     110        if( ($from_year != '') && ($from_month != '') && ($from_day != "") && 
     111            ($to_year != '') && ($to_month != '') && ($to_day != "")) { 
    112112            $this->setWhere($column . ' >= ? AND ' . $column . ' < date(?)'); 
    113113            $return[] = $date1; 
     
    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; 
     
    130130 
    131131            if (count($arr) > 1) { 
    132                 if(! is_null($data)) $item .= $ItemStr . " = ? OR "; 
     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 ") . ")"; 
     139        if( count($arr) > 1)  $item = '(' . rtrim($item, ' OR ') . ")"; 
    140140        $this->setWhere($item); 
    141141        return $return; 
     
    149149        if ($arr) { 
    150150            foreach ($arr as $data) { 
    151                 if ($data != "不明") { 
     151                if ($data != '不明') { 
    152152                    $item .= " OR ${ItemStr} = ?"; 
    153153                    $return[] = $data; 
     
    194194        } 
    195195 
    196         $statement = "(" . rtrim($statement, " OR ") . ")"; 
     196        $statement = '(' . rtrim($statement, ' OR ') . ")"; 
    197197 
    198198        if ($this->where) { 
    199199 
    200             $this->where .= " AND " . $statement; 
     200            $this->where .= ' AND ' . $statement; 
    201201 
    202202        } else { 
    203203 
    204             $this->where = "WHERE " . $statement; 
     204            $this->where = 'WHERE ' . $statement; 
    205205        } 
    206206    } 
    207207 
    208208    function setWhere($where) { 
    209         if ($where != "") { 
     209        if ($where != '') { 
    210210            if ($this->where) { 
    211211 
    212                 $this->where .= " AND " . $where; 
     212                $this->where .= ' AND ' . $where; 
    213213 
    214214            } else { 
    215215 
    216                 $this->where = "WHERE " . $where; 
     216                $this->where = 'WHERE ' . $where; 
    217217            } 
    218218        } 
     
    221221    function setOrder($order) { 
    222222 
    223             $this->order =  "ORDER BY " . $order; 
     223            $this->order =  'ORDER BY ' . $order; 
    224224 
    225225    } 
     
    227227    function setGroup($group) { 
    228228 
    229         $this->group =  "GROUP BY " . $group; 
     229        $this->group =  'GROUP BY ' . $group; 
    230230 
    231231    } 
     
    235235        if (is_numeric($limit) and is_numeric($offset)) { 
    236236 
    237             $this->limit = " LIMIT " .$limit; 
    238             $this->offset = " OFFSET " .$offset; 
     237            $this->limit = ' LIMIT ' .$limit; 
     238            $this->offset = ' OFFSET ' .$offset; 
    239239        } 
    240240    } 
    241241 
    242242    function clearSql() { 
    243         $this->select = ""; 
    244         $this->where = ""; 
    245         $this->group = ""; 
    246         $this->order = ""; 
    247         $this->limit = ""; 
    248         $this->offset = ""; 
     243        $this->select = ''; 
     244        $this->where = ''; 
     245        $this->group = ''; 
     246        $this->order = ''; 
     247        $this->limit = ''; 
     248        $this->offset = ''; 
    249249    } 
    250250 
Note: See TracChangeset for help on using the changeset viewer.