Changeset 16734


Ignore:
Timestamp:
2007/11/07 17:51:51 (15 years ago)
Author:
satou
Message:

#119
SQLにdate関数を用いる必要が無い。

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/beta/data/class/SC_SelectSql.php

    r15120 r16734  
    7373    //--¡¡´ü´Ö¸¡º÷¡Ê¡ûǯ¡û·î¡ûÆü¤«¢·¡ûǯ¡û·î¡ûÆü¤Þ¤Ç¡Ë 
    7474    function selectTermRange($from_year, $from_month, $from_day, $to_year, $to_month, $to_day, $column) { 
    75  
    7675        // FROM 
    77         $date1 = $from_year . "/" . $from_month . "/" . $from_day; 
     76        $date1 = $from_year. "/". $from_month. "/". $from_day; 
    7877         
    7978        // TO 
    80         $date2 = mktime (0, 0, 0, $to_month, $to_day,  $to_year); 
    81         $date2 = $date2 + 86400; 
    82         // SQLʸ¤Îdate´Ø¿ô¤ËÍ¿¤¨¤ë¥Õ¥©¡¼¥Þ¥Ã¥È¤Ï¡¢yyyy/mm/dd¤Ç»ØÄꤹ¤ë¡£ 
    83         $date2 = date('Y/m/d', $date2); 
     79        $to_day += 1;   // °ìÆü¿Ê¤á¤ë 
     80        $date2 = $to_year. "/". $to_month . "/". $to_day; 
    8481         
    8582        // ³«»Ï´ü´Ö¤À¤±»ØÄê¤Î¾ì¹ç 
    86         if( ( $from_year != "" ) && ( $from_month != "" ) && ( $from_day != "" ) && ( $to_year == "" ) && ( $to_month == "" ) && ( $to_day == "" ) ) { 
    87             $this->setWhere( $column ." >= '" . $date1 . "'"); 
    88         } 
    89  
    90         //¡¡³«»Ï¡Á½ªÎ» 
    91         if( ( $from_year != "" ) && ( $from_month != "" ) && ( $from_day != "" ) &&  
    92             ( $to_year != "" ) && ( $to_month != "" ) && ( $to_day != "" ) ) { 
    93             $this->setWhere( $column ." >= '" . $date1 ."' AND ". $column . " < date('" . $date2 . "')" ); 
    94         } 
    95  
     83        if (($from_year != "") && ($from_month != "") && ($from_day != "") && ($to_year == "") && ($to_month == "") && ($to_day == "")) { 
     84            $this->setWhere($column. " >= '". $date1. "'"); 
     85        } 
     86         
     87        // ³«»Ï¡Á½ªÎ» 
     88        if (($from_year != "") && ($from_month != "") && ($from_day != "") && ($to_year != "") && ($to_month != "") && ($to_day != "")) { 
     89            $this->setWhere($column ." >= '" . $date1 ."' AND ". $column . " < '" . $date2 . "'"); 
     90        } 
     91         
    9692        // ½ªÎ»´ü´Ö¤À¤±»ØÄê¤Î¾ì¹ç 
    97         if( ( $from_year == "" ) && ( $from_month == "" ) && ( $from_day == "" ) && ( $to_year != "" ) && ( $to_month != "" ) && ( $to_day != "" ) ) { 
    98             $this->setWhere( $column ." < date('" . $date2 . "')"); 
     93        if(($from_year == "") && ($from_month == "") && ($from_day == "") && ($to_year != "") && ($to_month != "") && ($to_day != "")) { 
     94            $this->setWhere($column ." < '" . $date2 . "'"); 
    9995        } 
    10096        return $return; 
Note: See TracChangeset for help on using the changeset viewer.