- Timestamp:
- 2007/07/20 15:58:59 (19 years ago)
- Location:
- branches/feature-module-update
- Files:
-
- 1 edited
- 2 copied
-
. (copied) (copied from branches/rel) (1 prop)
-
data (copied) (copied from branches/rel/data)
-
data/class/SC_SelectSql.php (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/feature-module-update
-
Property
svn:ignore
set to
.cache
.settings
.projectOptions
-
Property
svn:ignore
set to
-
branches/feature-module-update/data/class/SC_SelectSql.php
r14911 r15078 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 == 2) { 35 35 $this->sql .= $this->order; … … 41 41 } 42 42 43 // ¸¡º÷ÍÑ43 // 検索用 44 44 function addSearchStr($val) { 45 45 $return = sfManualEscape($val); … … 48 48 } 49 49 50 //-- Èϰϸ¡º÷¡Ê¡û¡¡¢·¡¡¡û¡¡¤Þ¤Ç¡Ë50 //-- 範囲検索(○ ~ ○ まで) 51 51 function selectRange($from, $to, $column) { 52 52 53 // ¤¢¤ëñ°Ì¤Î¤ß¸¡º÷($from = $to)53 // ある単位のみ検索($from = $to) 54 54 if( $from == $to ) { 55 55 $this->setWhere( $column ." = ?" ); 56 56 $return = array($from); 57 // ¡¡¢·$to¤Þ¤Ç¸¡º÷57 // ~$toまで検索 58 58 } elseif( strlen($from) == 0 && strlen($to) > 0 ) { 59 59 $this->setWhere( $column ." <= ? "); 60 60 $return = array($to); 61 // ¡¡¢·$from°Ê¾å¤ò¸¡º÷61 // ~$from以上を検索 62 62 } elseif( strlen($from) > 0 && strlen($to) == 0 ) { 63 63 $this->setWhere( $column ." >= ? "); 64 64 $return = array($from); 65 // ¡¡$from¢·$to¤Î¸¡º÷65 // $from~$toの検索 66 66 } else { 67 67 $this->setWhere( $column ." BETWEEN ? AND ?" ); … … 71 71 } 72 72 73 //-- ¡¡´ü´Ö¸¡º÷¡Ê¡ûǯ¡û·î¡ûÆü¤«¢·¡ûǯ¡û·î¡ûÆü¤Þ¤Ç¡Ë73 //-- 期間検索(○年○月○日か~○年○月○日まで) 74 74 function selectTermRange($from_year, $from_month, $from_day, $to_year, $to_month, $to_day, $column) { 75 75 … … 80 80 $date2 = mktime (0, 0, 0, $to_month, $to_day, $to_year); 81 81 $date2 = $date2 + 86400; 82 // SQL ʸ¤Îdate´Ø¿ô¤ËÍ¿¤¨¤ë¥Õ¥©¡¼¥Þ¥Ã¥È¤Ï¡¢yyyy/mm/dd¤Ç»ØÄꤹ¤ë¡£82 // SQL文のdate関数に与えるフォーマットは、yyyy/mm/ddで指定する。 83 83 $date2 = date('Y/m/d', $date2); 84 84 85 // ³«»Ï´ü´Ö¤À¤±»ØÄê¤Î¾ì¹ç85 // 開始期間だけ指定の場合 86 86 if( ( $from_year != "" ) && ( $from_month != "" ) && ( $from_day != "" ) && ( $to_year == "" ) && ( $to_month == "" ) && ( $to_day == "" ) ) { 87 87 $this->setWhere( $column ." >= '" . $date1 . "'"); 88 88 } 89 89 90 // ¡¡³«»Ï¡Á½ªÎ»90 // 開始〜終了 91 91 if( ( $from_year != "" ) && ( $from_month != "" ) && ( $from_day != "" ) && 92 92 ( $to_year != "" ) && ( $to_month != "" ) && ( $to_day != "" ) ) { … … 94 94 } 95 95 96 // ½ªÎ»´ü´Ö¤À¤±»ØÄê¤Î¾ì¹ç96 // 終了期間だけ指定の場合 97 97 if( ( $from_year == "" ) && ( $from_month == "" ) && ( $from_day == "" ) && ( $to_year != "" ) && ( $to_month != "" ) && ( $to_day != "" ) ) { 98 98 $this->setWhere( $column ." < date('" . $date2 . "')"); … … 101 101 } 102 102 103 // checkbox ¤Ê¤É¤ÇƱ°ì¥«¥é¥àÆâ¤Çñ°ì¡¢¤â¤·¤¯¤ÏÊ£¿ôÁªÂò»è¤¬Í¤ë¾ì¹ç¡¡Îã: AND ( sex = xxx OR sex = xxx OR sex = xxx ) AND ...103 // checkboxなどで同一カラム内で単一、もしくは複数選択肢が有る場合 例: AND ( sex = xxx OR sex = xxx OR sex = xxx ) AND ... 104 104 function setItemTerm( $arr, $ItemStr ) { 105 105 … … 119 119 } 120 120 121 // ¡¡NULLÃͤ¬É¬Íפʾì¹ç121 // NULL値が必要な場合 122 122 function setItemTermWithNull( $arr, $ItemStr ) { 123 123 … … 126 126 if ( $arr ){ 127 127 foreach( $arr as $data ) { 128 if ($data != " ÉÔÌÀ") {128 if ($data != "不明") { 129 129 $item .= " OR ${ItemStr} = ?"; 130 130 $return[] = $data; … … 137 137 return $return; 138 138 } 139 // NULL ¤â¤·¤¯¤Ï''¤Ç¸¡º÷¤¹¤ë¾ì¹ç139 // NULLもしくは''で検索する場合 140 140 function setItemTermWithNullAndSpace( $arr, $ItemStr ) { 141 141 $count = count($arr); … … 157 157 158 158 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 配列の構造例 162 162 if ( $_POST['show_site1'] ) $arrShowsite_1 = array( "column" => "show_site1", 163 163 "value" => $_POST['show_site1'] );
Note: See TracChangeset
for help on using the changeset viewer.
