Ignore:
Timestamp:
2007/07/20 15:58:59 (17 years ago)
Author:
nanasess
Message:

r15064 から svn cp
とりあえず暫定コミット.

  • UTF-8 に変更
  • slib.php, glib.php のクラス化
  • LC_Page の抽象化(一部)
Location:
branches/feature-module-update
Files:
1 edited
2 copied

Legend:

Unmodified
Added
Removed
  • branches/feature-module-update

    • Property svn:ignore set to
      .cache

      .settings

      .projectOptions
  • branches/feature-module-update/data/class/SC_SelectSql.php

    r14911 r15078  
    66 */ 
    77 
    8 /* ---- SQLʸ¤òºî¤ë¥¯¥é¥¹ ---- */ 
     8/* ---- SQL文を作るクラス ---- */ 
    99class SC_SelectSql { 
    1010     
     
    2020    var $arrVal; 
    2121 
    22     //--¡¡¥³¥ó¥¹¥È¥é¥¯¥¿¡£ 
     22    //-- コンストラクタ。 
    2323    function SC_SelectSql($array = "") { 
    2424        if (is_array($array)) { 
     
    2727    } 
    2828 
    29     //-- SQLʬÀ¸À® 
     29    //-- SQL分生成 
    3030    function getSql( $mode = "" ){ 
    3131        $this->sql = $this->select ." ". $this->where ." ". $this->group ." "; 
    3232                         
    33         // $mode == 1 ¤Ï limit & offset̵¤·                      
     33        // $mode == 1 は limit & offset無し                         
    3434        if ($mode == 2) { 
    3535            $this->sql .= $this->order; 
     
    4141    } 
    4242 
    43         // ¸¡º÷ÍÑ 
     43        // 検索用 
    4444    function addSearchStr($val) { 
    4545        $return = sfManualEscape($val); 
     
    4848    } 
    4949     
    50     //-- Èϰϸ¡º÷¡Ê¡û¡¡¢·¡¡¡û¡¡¤Þ¤Ç¡Ë 
     50    //-- 範囲検索(○ ~ ○ まで) 
    5151    function selectRange($from, $to, $column) { 
    5252 
    53         // ¤¢¤ëñ°Ì¤Î¤ß¸¡º÷($from = $to) 
     53        // ある単位のみ検索($from = $to) 
    5454        if(  $from == $to ) { 
    5555            $this->setWhere( $column ." = ?" ); 
    5656            $return = array($from); 
    57         //¡¡¢·$to¤Þ¤Ç¸¡º÷ 
     57        // ~$toまで検索 
    5858        } elseif(  strlen($from) == 0 && strlen($to) > 0 ) { 
    5959            $this->setWhere( $column ." <= ? ");  
    6060            $return = array($to); 
    61         //¡¡¢·$from°Ê¾å¤ò¸¡º÷ 
     61        // ~$from以上を検索 
    6262        } elseif(  strlen($from) > 0 && strlen($to) == 0 ) { 
    6363            $this->setWhere( $column ." >= ? "); 
    6464            $return = array($from); 
    65         //¡¡$from¢·$to¤Î¸¡º÷ 
     65        // $from~$toの検索 
    6666        } else { 
    6767            $this->setWhere( $column ." BETWEEN ? AND ?" );  
     
    7171    } 
    7272 
    73     //--¡¡´ü´Ö¸¡º÷¡Ê¡ûǯ¡û·î¡ûÆü¤«¢·¡ûǯ¡û·î¡ûÆü¤Þ¤Ç¡Ë 
     73    //-- 期間検索(○年○月○日か~○年○月○日まで) 
    7474    function selectTermRange($from_year, $from_month, $from_day, $to_year, $to_month, $to_day, $column) { 
    7575 
     
    8080        $date2 = mktime (0, 0, 0, $to_month, $to_day,  $to_year); 
    8181        $date2 = $date2 + 86400; 
    82         // SQLʸ¤Îdate´Ø¿ô¤ËÍ¿¤¨¤ë¥Õ¥©¡¼¥Þ¥Ã¥È¤Ï¡¢yyyy/mm/dd¤Ç»ØÄꤹ¤ë¡£ 
     82        // SQL文のdate関数に与えるフォーマットは、yyyy/mm/ddで指定する。 
    8383        $date2 = date('Y/m/d', $date2); 
    8484         
    85         // ³«»Ï´ü´Ö¤À¤±»ØÄê¤Î¾ì¹ç 
     85        // 開始期間だけ指定の場合 
    8686        if( ( $from_year != "" ) && ( $from_month != "" ) && ( $from_day != "" ) && ( $to_year == "" ) && ( $to_month == "" ) && ( $to_day == "" ) ) { 
    8787            $this->setWhere( $column ." >= '" . $date1 . "'"); 
    8888        } 
    8989 
    90         //¡¡³«»Ï¡Á½ªÎ» 
     90        // 開始〜終了 
    9191        if( ( $from_year != "" ) && ( $from_month != "" ) && ( $from_day != "" ) &&  
    9292            ( $to_year != "" ) && ( $to_month != "" ) && ( $to_day != "" ) ) { 
     
    9494        } 
    9595 
    96         // ½ªÎ»´ü´Ö¤À¤±»ØÄê¤Î¾ì¹ç 
     96        // 終了期間だけ指定の場合 
    9797        if( ( $from_year == "" ) && ( $from_month == "" ) && ( $from_day == "" ) && ( $to_year != "" ) && ( $to_month != "" ) && ( $to_day != "" ) ) { 
    9898            $this->setWhere( $column ." < date('" . $date2 . "')"); 
     
    101101    }    
    102102 
    103     // checkbox¤Ê¤É¤ÇƱ°ì¥«¥é¥àÆâ¤Çñ°ì¡¢¤â¤·¤¯¤ÏÊ£¿ôÁªÂò»è¤¬Í­¤ë¾ì¹ç¡¡Îã: AND ( sex = xxx OR sex = xxx OR sex = xxx  ) AND ...  
     103    // checkboxなどで同一カラム内で単一、もしくは複数選択肢が有る場合 例: AND ( sex = xxx OR sex = xxx OR sex = xxx  ) AND ...  
    104104    function setItemTerm( $arr, $ItemStr ) { 
    105105 
     
    119119    } 
    120120 
    121     //¡¡NULLÃͤ¬É¬Íפʾì¹ç 
     121    // NULL値が必要な場合 
    122122    function setItemTermWithNull( $arr, $ItemStr ) { 
    123123 
     
    126126        if ( $arr ){ 
    127127            foreach( $arr as $data ) {   
    128                 if ($data != "ÉÔÌÀ") { 
     128                if ($data != "不明") { 
    129129                    $item .= " OR ${ItemStr} = ?"; 
    130130                    $return[] = $data; 
     
    137137        return $return; 
    138138    } 
    139     // NULL¤â¤·¤¯¤Ï''¤Ç¸¡º÷¤¹¤ë¾ì¹ç 
     139    // NULLもしくは''で検索する場合 
    140140    function setItemTermWithNullAndSpace( $arr, $ItemStr ) { 
    141141        $count = count($arr); 
     
    157157 
    158158 
    159     /* Ê£¿ô¤Î¥«¥é¥à¤ÇOR¤ÇÍ¥À踡º÷¤¹¤ë¾ì¹ç¡¡Î㡧¡¡AND ( item_flag1 = xxx OR item_flag2 = xxx OR item_flag3 = xxx  ) AND ...  
    160  
    161         ÇÛÎó¤Î¹½Â¤Îã¡¡ 
     159    /* 複数のカラムでORで優先検索する場合 例: AND ( item_flag1 = xxx OR item_flag2 = xxx OR item_flag3 = xxx  ) AND ...  
     160 
     161        配列の構造例  
    162162        if ( $_POST['show_site1'] ) $arrShowsite_1 = array( "column" => "show_site1", 
    163163                                                            "value"  => $_POST['show_site1'] ); 
Note: See TracChangeset for help on using the changeset viewer.