Changeset 11730 for branches/comu/data/class/SC_SelectSql.php
- Timestamp:
- 2007/03/11 06:27:25 (19 years ago)
- File:
-
- 1 edited
-
branches/comu/data/class/SC_SelectSql.php (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/comu/data/class/SC_SelectSql.php
r11729 r11730 6 6 */ 7 7 8 /* ---- SQL 文を作るクラス---- */8 /* ---- SQLʸ¤òºî¤ë¥¯¥é¥¹ ---- */ 9 9 class SC_SelectSql { 10 10 … … 20 20 var $arrVal; 21 21 22 //-- コンストラクタ。22 //--¡¡¥³¥ó¥¹¥È¥é¥¯¥¿¡£ 23 23 function SC_SelectSql($array = "") { 24 24 if (is_array($array)) { … … 27 27 } 28 28 29 //-- SQL 分生成29 //-- SQLʬÀ¸À® 30 30 function getSql( $mode = "" ){ 31 31 $this->sql = $this->select ." ". $this->where ." ". $this->group ." "; 32 32 33 // $mode == 1 は limit & offset無し33 // $mode == 1 ¤Ï limit & offset̵¤· 34 34 if ( $mode != 1 ){ 35 35 $this->sql .= $this->order . " " .$this->limit ." ". $this->offset; … … 40 40 } 41 41 42 // 検索用42 // ¸¡º÷ÍÑ 43 43 function addSearchStr($val) { 44 44 $return = sfManualEscape($val); … … 47 47 } 48 48 49 //-- 範囲検索(○ ~ ○ まで)49 //-- Èϰϸ¡º÷¡Ê¡û¡¡¢·¡¡¡û¡¡¤Þ¤Ç¡Ë 50 50 function selectRange($from, $to, $column) { 51 51 52 // ある単位のみ検索($from = $to)52 // ¤¢¤ëñ°Ì¤Î¤ß¸¡º÷($from = $to) 53 53 if( $from == $to ) { 54 54 $this->setWhere( $column ." = ?" ); 55 55 $return = array($from); 56 // ~$toまで検索56 //¡¡¢·$to¤Þ¤Ç¸¡º÷ 57 57 } elseif( strlen($from) == 0 && strlen($to) > 0 ) { 58 58 $this->setWhere( $column ." <= ? "); 59 59 $return = array($to); 60 // ~$from以上を検索60 //¡¡¢·$from°Ê¾å¤ò¸¡º÷ 61 61 } elseif( strlen($from) > 0 && strlen($to) == 0 ) { 62 62 $this->setWhere( $column ." >= ? "); 63 63 $return = array($from); 64 // $from~$toの検索64 //¡¡$from¢·$to¤Î¸¡º÷ 65 65 } else { 66 66 $this->setWhere( $column ." BETWEEN ? AND ?" ); … … 70 70 } 71 71 72 //-- 期間検索(○年○月○日か~○年○月○日まで)72 //--¡¡´ü´Ö¸¡º÷¡Ê¡ûǯ¡û·î¡ûÆü¤«¢·¡ûǯ¡û·î¡ûÆü¤Þ¤Ç¡Ë 73 73 function selectTermRange($from_year, $from_month, $from_day, $to_year, $to_month, $to_day, $column) { 74 74 … … 81 81 $date2 = date('y/m/d', $date2); 82 82 83 // 開始期間だけ指定の場合83 // ³«»Ï´ü´Ö¤À¤±»ØÄê¤Î¾ì¹ç 84 84 if( ( $from_year != "" ) && ( $from_month != "" ) && ( $from_day != "" ) && ( $to_year == "" ) && ( $to_month == "" ) && ( $to_day == "" ) ) { 85 85 $this->setWhere( $column ." >= '" . $date1 . "'"); 86 86 } 87 87 88 // 開始〜終了88 //¡¡³«»Ï¡Á½ªÎ» 89 89 if( ( $from_year != "" ) && ( $from_month != "" ) && ( $from_day != "" ) && 90 90 ( $to_year != "" ) && ( $to_month != "" ) && ( $to_day != "" ) ) { … … 92 92 } 93 93 94 // 終了期間だけ指定の場合94 // ½ªÎ»´ü´Ö¤À¤±»ØÄê¤Î¾ì¹ç 95 95 if( ( $from_year == "" ) && ( $from_month == "" ) && ( $from_day == "" ) && ( $to_year != "" ) && ( $to_month != "" ) && ( $to_day != "" ) ) { 96 96 $this->setWhere( $column ." < date('" . $date2 . "')"); … … 99 99 } 100 100 101 // checkbox などで同一カラム内で単一、もしくは複数選択肢が有る場合 例: AND ( sex = xxx OR sex = xxx OR sex = xxx ) AND ...101 // checkbox¤Ê¤É¤ÇƱ°ì¥«¥é¥àÆâ¤Çñ°ì¡¢¤â¤·¤¯¤ÏÊ£¿ôÁªÂò»è¤¬Í¤ë¾ì¹ç¡¡Îã: AND ( sex = xxx OR sex = xxx OR sex = xxx ) AND ... 102 102 function setItemTerm( $arr, $ItemStr ) { 103 103 … … 117 117 } 118 118 119 // NULL値が必要な場合119 //¡¡NULLÃͤ¬É¬Íפʾì¹ç 120 120 function setItemTermWithNull( $arr, $ItemStr ) { 121 121 … … 124 124 if ( $arr ){ 125 125 foreach( $arr as $data ) { 126 if ($data != " 不明") {126 if ($data != "ÉÔÌÀ") { 127 127 $item .= " OR ${ItemStr} = ?"; 128 128 $return[] = $data; … … 135 135 return $return; 136 136 } 137 // NULL もしくは''で検索する場合137 // NULL¤â¤·¤¯¤Ï''¤Ç¸¡º÷¤¹¤ë¾ì¹ç 138 138 function setItemTermWithNullAndSpace( $arr, $ItemStr ) { 139 139 $count = count($arr); … … 155 155 156 156 157 /* 複数のカラムでORで優先検索する場合 例:AND ( item_flag1 = xxx OR item_flag2 = xxx OR item_flag3 = xxx ) AND ...158 159 配列の構造例157 /* Ê£¿ô¤Î¥«¥é¥à¤ÇOR¤ÇÍ¥À踡º÷¤¹¤ë¾ì¹ç¡¡Îã¡§¡¡AND ( item_flag1 = xxx OR item_flag2 = xxx OR item_flag3 = xxx ) AND ... 158 159 ÇÛÎó¤Î¹½Â¤Îã¡¡ 160 160 if ( $_POST['show_site1'] ) $arrShowsite_1 = array( "column" => "show_site1", 161 161 "value" => $_POST['show_site1'] );
Note: See TracChangeset
for help on using the changeset viewer.
