Changeset 11729 for branches/comu/data/class/SC_SelectSql.php
- Timestamp:
- 2007/03/10 21:35:02 (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
r248 r11729 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.
