Changeset 4272
- Timestamp:
- Oct 3, 2007, 8:02:58 PM (13 years ago)
- Location:
- OpenPNE/trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
OpenPNE/trunk/webapp/lib/db/commu.php
r4127 r4272 1710 1710 $select = 'SELECT c_commu.*'; 1711 1711 1712 $where = ' WHERE true';1712 $wheres = array(); 1713 1713 $params = array(); 1714 1714 if ($c_commu_category_id) { 1715 $where .= ' ANDc_commu.c_commu_category_id = ?';1715 $wheres[] = 'c_commu.c_commu_category_id = ?'; 1716 1716 $params[] = $c_commu_category_id; 1717 1717 } … … 1721 1721 $word = check_search_word($word); 1722 1722 1723 $where .= ' AND(c_commu.name LIKE ? OR c_commu.info LIKE ?)';1723 $wheres[] = '(c_commu.name LIKE ? OR c_commu.info LIKE ?)'; 1724 1724 $params[] = '%'.$word.'%'; 1725 1725 $params[] = '%'.$word.'%'; 1726 1726 } 1727 } 1728 if ($wheres) { 1729 $where = ' WHERE ' . implode(' AND ', $wheres); 1730 } else { 1731 $where = ''; 1727 1732 } 1728 1733 … … 1799 1804 $sql = 'SELECT * FROM c_commu'; 1800 1805 1801 $where = ' WHERE true';1806 $wheres = array(); 1802 1807 $params = array(); 1803 1808 if ($search_word) { 1804 $where .= ' AND(name LIKE ? OR info LIKE ?)';1809 $wheres[] = '(name LIKE ? OR info LIKE ?)'; 1805 1810 $params[] = '%'.$search_word.'%'; 1806 1811 $params[] = '%'.$search_word.'%'; 1807 1812 } 1808 1813 if ($c_commu_category_id != 'all' && $c_commu_category_id) { 1809 $where .= ' ANDc_commu_category_id = ?';1814 $wheres[] = 'c_commu_category_id = ?'; 1810 1815 $params[] = intval($c_commu_category_id); 1816 } 1817 if ($wheres) { 1818 $where = ' WHERE ' . implode(' AND ', $wheres); 1819 } else { 1820 $where = ''; 1811 1821 } 1812 1822 -
OpenPNE/trunk/webapp/lib/db/member.php
r4269 r4272 241 241 $page_size = intval($page_size); 242 242 243 $where = " WHERE true";243 $wheres = array(); 244 244 $params = array(); 245 245 … … 247 247 if ($value) { 248 248 if ($key == 'image') { 249 $where .= " ANDimage_filename <> ''";249 $wheres[] = "image_filename <> ''"; 250 250 } else { 251 $where .= " AND ". db_escapeIdentifier($key) ." = ?";251 $wheres[] = db_escapeIdentifier($key) . ' = ?'; 252 252 $params[] = $value; 253 253 if ($key == 'birth_year') { 254 $where .= " ANDpublic_flag_birth_year = 'public'";254 $wheres[] = "public_flag_birth_year = 'public'"; 255 255 } 256 256 } … … 259 259 foreach ($cond_like as $key => $value) { 260 260 if ($value) { 261 $where .= " AND " . db_escapeIdentifier($key) . " LIKE ?";262 $params[] = '%' .$value.'%';261 $wheres[] = db_escapeIdentifier($key) . ' LIKE ?'; 262 $params[] = '%' . $value . '%'; 263 263 } 264 } 265 if ($wheres) { 266 $where = ' WHERE ' . implode(' AND ', $wheres); 267 } else { 268 $where = ''; 264 269 } 265 270 -
OpenPNE/trunk/webapp/lib/db/review.php
r3738 r4272 162 162 $from = " FROM c_review INNER JOIN c_review_comment USING (c_review_id)"; 163 163 164 $where = ' WHERE true';164 $wheres = array(); 165 165 $params = array(); 166 166 if ($keyword) { 167 $where .= ' ANDc_review.title LIKE ?';167 $wheres[] = 'c_review.title LIKE ?'; 168 168 $params[] = '%'.check_search_word($keyword).'%'; 169 169 } 170 170 if ($category_id) { 171 $where .= ' ANDc_review.c_review_category_id = ?';171 $wheres[] = 'c_review.c_review_category_id = ?'; 172 172 $params[] = intval($category_id); 173 } 174 if ($wheres) { 175 $where = ' WHERE ' . implode(' AND ', $wheres); 176 } else { 177 $where = ''; 173 178 } 174 179 -
OpenPNE/trunk/webapp/modules/admin/do/csv_member.php
r3591 r4272 38 38 * メンバーリスト取得 39 39 */ 40 function db_get_c_member_list($start_id, $end_id)40 function db_get_c_member_list($start_id, $end_id) 41 41 { 42 42 $params = array(); 43 $sql = 'SELECT c_member_id FROM c_member 44 $ sql .= ' WHERE true ';43 $sql = 'SELECT c_member_id FROM c_member'; 44 $wheres = array(); 45 45 if ($start_id > 1) { 46 $ sql .= ' AND c_member_id >= ?';46 $wheres[] = 'c_member_id >= ?'; 47 47 $params[] = $start_id; 48 48 } 49 49 if ($end_id > 0) { 50 $ sql .= ' AND c_member_id <= ?';50 $wheres[] = 'c_member_id <= ?'; 51 51 $params[] = $end_id; 52 52 } 53 if ($wheres) { 54 $where = ' WHERE ' . implode(' AND ', $wheres); 55 } else { 56 $where = ''; 57 } 58 $sql .= $where; 53 59 $sql .= ' ORDER BY c_member_id'; 54 60 $ids = db_get_col($sql, $params); -
OpenPNE/trunk/webapp/modules/admin/lib/db_admin.php
r4270 r4272 547 547 { 548 548 $sql = 'SELECT c_member_id'. 549 ' FROM c_member'. 550 ' WHERE true'; 549 ' FROM c_member'; 550 551 $wheres = array(); 551 552 552 553 //開始年 553 554 if (!empty($cond_list['s_year'])) { 554 $ sql .= ' ANDbirth_year >= ?';555 $wheres[] = 'birth_year >= ?'; 555 556 $params[] = $cond_list['s_year']; 556 557 } 557 558 //終了年 558 559 if (!empty($cond_list['e_year'])) { 559 $ sql .= ' ANDbirth_year <= ?';560 $wheres[] = 'birth_year <= ?'; 560 561 $params[] = $cond_list['e_year']; 561 562 } … … 563 564 // 誕生日による絞り込みの場合は、誕生年が0のメンバーを除外する 564 565 if (!empty($cond_list['s_year']) || !empty($cond_list['e_year'])) { 565 $ sql .= ' ANDbirth_year <> 0';566 $wheres[] = 'birth_year <> 0'; 566 567 } 567 568 … … 571 572 switch($cond_list['last_login']) { 572 573 case 1: //3日以内 573 $ sql .= ' ANDaccess_date >= ?';574 $wheres[] = 'access_date >= ?'; 574 575 $params[] = date('Y-m-d', strtotime('-3 day')); 575 576 break; 576 577 case 2: //3~7日以内 577 $ sql .= ' ANDaccess_date >= ? AND access_date < ?';578 $wheres[] = 'access_date >= ? AND access_date < ?'; 578 579 $params[] = date('Y-m-d', strtotime('-7 day')); 579 580 $params[] = date('Y-m-d', strtotime('-3 day')); 580 581 break; 581 582 case 3: //7~30日以内 582 $ sql .= ' ANDaccess_date >= ? AND access_date < ?';583 $wheres[] = 'access_date >= ? AND access_date < ?'; 583 584 $params[] = date('Y-m-d', strtotime('-30 day')); 584 585 $params[] = date('Y-m-d', strtotime('-7 day')); 585 586 break; 586 587 case 4: //30日以上 587 $ sql .= ' ANDaccess_date > ? AND access_date < ?';588 $wheres[] = 'access_date > ? AND access_date < ?'; 588 589 $params[] = '0000-00-00 00:00:00'; 589 590 $params[] = date('Y-m-d', strtotime('-30 day')); 590 591 break; 591 592 case 5: //未ログイン 592 $ sql .= ' ANDaccess_date = ?';593 $wheres[] = 'access_date = ?'; 593 594 $params[] = '0000-00-00 00:00:00'; 594 595 break; … … 596 597 } 597 598 599 if ($wheres) { 600 $where = ' WHERE ' . implode(' AND ', $wheres); 601 } else { 602 $where = ''; 603 } 604 $sql .= $where; 605 598 606 // --- ソートオーダーここから 599 607 … … 687 695 if (!empty($cond_list['is_pc_address']) || !empty($cond_list['is_ktai_address'])) { 688 696 689 $sql = 'SELECT c_member_id FROM c_member_secure WHERE true'; 697 $sql = 'SELECT c_member_id FROM c_member_secure'; 698 $wheres = array(); 690 699 691 700 //PCアドレスの有無で絞る 692 701 if ($cond_list['is_pc_address'] == 1) { 693 $ sql .= " AND pc_address <> ''";694 } else 695 $ sql .= " AND pc_address = ''";702 $wheres[] = "pc_address <> ''"; 703 } elseif ($cond_list['is_pc_address'] == 2) { 704 $wheres[] = "pc_address = ''"; 696 705 } 697 706 698 707 //携帯アドレスの有無で絞る 699 708 if ($cond_list['is_ktai_address'] == 1) { 700 $sql .= " AND ktai_address <> '' "; 701 } else if ($cond_list['is_ktai_address'] == 2) { 702 $sql .= " AND ktai_address = '' "; 703 } 709 $wheres[] = "ktai_address <> ''"; 710 } elseif ($cond_list['is_ktai_address'] == 2) { 711 $wheres[] = "ktai_address = ''"; 712 } 713 714 if ($wheres) { 715 $where = ' WHERE ' . implode(' AND ', $wheres); 716 } else { 717 $where = ''; 718 } 719 $sql .= $where; 704 720 705 721 $temp_ids = db_get_col($sql); … … 1605 1621 $page_size = intval($page_size); 1606 1622 1607 $where = " WHERE true "; 1623 $wheres = array(); 1624 $params = array(); 1608 1625 1609 1626 //指定された条件で絞っていく 1610 if ($s_access_date != "") { 1611 $where = $where . " and access_date >= ?"; 1612 $params = array($s_access_date); 1613 } 1614 1615 if ($e_access_date != "") { 1616 $where = $where . " and access_date < ?"; 1617 $params = array($e_access_date); 1627 if ($s_access_date != '') { 1628 $wheres[] = 'access_date >= ?'; 1629 $params[] = $s_access_date; 1630 } 1631 1632 if ($e_access_date != '') { 1633 $wheres[] = 'access_date < ?'; 1634 $params[] = $e_access_date; 1635 } 1636 1637 if ($wheres) { 1638 $where = ' WHERE ' . implode(' AND ', $wheres); 1639 } else { 1640 $where = ''; 1618 1641 } 1619 1642 … … 1855 1878 $page_size = intval($page_size); 1856 1879 1857 $where = " WHERE true";1880 $wheres = array(); 1858 1881 1859 1882 if ($keyword) { 1860 1883 //全角空白を半角に統一 1861 $keyword = str_replace(" ", " ", $keyword); 1862 $keyword_list = explode(" ", $keyword); 1863 1864 for($i=0;$i < count($keyword_list);$i++) { 1865 $keyword = check_search_word( $keyword_list[$i] ); 1866 1867 $where .= " AND (c_diary.subject LIKE ?"; 1868 $where .= " OR c_diary.body LIKE ? )"; 1869 $params[]="%$keyword%"; 1870 $params[]="%$keyword%"; 1871 } 1884 $keyword = str_replace(' ', ' ', $keyword); 1885 $keyword_list = explode(' ', $keyword); 1886 1887 for ($i = 0; $i < count($keyword_list); $i++) { 1888 $keyword = check_search_word($keyword_list[$i]); 1889 1890 $wheres[] = '(c_diary.subject LIKE ? OR c_diary.body LIKE ?)'; 1891 $params[] = '%' . $keyword . '%'; 1892 $params[] = '%' . $keyword . '%'; 1893 } 1894 } 1895 if ($wheres) { 1896 $where = ' WHERE ' . implode(' AND ', $wheres); 1897 } else { 1898 $where = ''; 1872 1899 } 1873 1900 … … 1933 1960 $page_size = intval($page_size); 1934 1961 1935 $where = " WHERE true ";1962 $wheres = array(); 1936 1963 1937 1964 if ($keyword) { 1938 1965 //全角空白を半角に統一 1939 $keyword = str_replace(" ", " ", $keyword); 1940 $keyword_list = explode(" ", $keyword); 1941 1942 for($i=0;$i < count($keyword_list);$i++) { 1943 $keyword = check_search_word( $keyword_list[$i] ); 1944 1945 $where .= " AND (c_diary_comment.body LIKE ?)"; 1946 $params[] = "%$keyword%"; 1947 } 1948 } 1949 1966 $keyword = str_replace(' ', ' ', $keyword); 1967 $keyword_list = explode(' ', $keyword); 1968 1969 for($i = 0; $i < count($keyword_list); $i++) { 1970 $keyword = check_search_word($keyword_list[$i]); 1971 1972 $wheres[] = 'c_diary_comment.body LIKE ?'; 1973 $params[] = '%' . $keyword . '%'; 1974 } 1975 } 1976 1977 if ($wheres) { 1978 $where = ' WHERE ' . implode(' AND ', $wheres); 1979 } else { 1980 $where = ''; 1981 } 1982 1950 1983 $select = "SELECT c_diary_comment.*, c_diary.subject"; 1951 1984 $from = " FROM c_diary_comment" … … 2012 2045 $page_size = intval($page_size); 2013 2046 2014 $where = " WHERE true ";2047 $wheres = array(); 2015 2048 2016 2049 if ($keyword) { 2017 $keyword = str_replace( "?@", " ", $keyword);2018 $keyword_list = explode( " ", $keyword);2050 $keyword = str_replace(' ', ' ', $keyword); 2051 $keyword_list = explode(' ', $keyword); 2019 2052 2020 for($i =0;$i < count($keyword_list);$i++) {2021 $keyword = check_search_word( $keyword_list[$i]);2053 for($i = 0; $i < count($keyword_list); $i++) { 2054 $keyword = check_search_word($keyword_list[$i]); 2022 2055 2023 $where .= " AND ((name LIKE ? )"; 2024 $where .= " OR (info LIKE ? ))"; 2025 $params[]="%$keyword%"; 2026 $params[]="%$keyword%"; 2027 } 2028 } 2029 2056 $wheres[] = '(name LIKE ? OR info LIKE ?)'; 2057 $params[] = '%' . $keyword . '%'; 2058 $params[] = '%' . $keyword . '%'; 2059 } 2060 } 2061 2062 if ($wheres) { 2063 $where = ' WHERE ' . implode(' AND ', $wheres); 2064 } else { 2065 $where = ''; 2066 } 2067 2030 2068 $select = "SELECT * "; 2031 2069 $from = " FROM c_commu"; … … 2174 2212 $page_size = intval($page_size); 2175 2213 2176 $where = " where true ";2214 $wheres = array(); 2177 2215 2178 2216 if ($keyword) { 2179 $keyword = str_replace("?@", " ", $keyword); 2180 $keyword_list = explode(" ", $keyword); 2181 2182 for($i=0;$i < count($keyword_list);$i++) { 2183 $keyword = check_search_word( $keyword_list[$i] ); 2184 2185 $where .= " AND (ctc.body like ? "; 2186 $where .= " OR ct.name like ? "; 2187 $where .= " OR c.name like ? ) "; 2188 $params[]="%$keyword%"; 2189 $params[]="%$keyword%"; 2190 $params[]="%$keyword%"; 2191 } 2217 $keyword = str_replace(' ', ' ', $keyword); 2218 $keyword_list = explode(' ', $keyword); 2219 2220 for ($i = 0; $i < count($keyword_list); $i++) { 2221 $keyword = check_search_word($keyword_list[$i]); 2222 2223 $wheres[] = '(ctc.body like ? OR ct.name like ? OR c.name like ?)'; 2224 $params[] = '%' . $keyword . '%'; 2225 $params[] = '%' . $keyword . '%'; 2226 $params[] = '%' . $keyword . '%'; 2227 } 2228 } 2229 2230 if ($wheres) { 2231 $where = ' WHERE ' . implode(' AND ', $wheres); 2232 } else { 2233 $where = ''; 2192 2234 } 2193 2235 … … 2276 2318 $page_size = intval($page_size); 2277 2319 2278 $where = " where true ";2320 $wheres = array(); 2279 2321 2280 2322 if ($keyword) { 2281 2323 //全角空白を半角に統一 2282 $keyword = str_replace(" ", " ", $keyword); 2283 $keyword_list = explode(" ", $keyword); 2284 2285 for($i=0;$i < count($keyword_list);$i++) { 2286 $keyword = check_search_word( $keyword_list[$i] ); 2287 2288 $where .= " and c_review_comment.body like ? "; 2289 $params[]="%$keyword%"; 2290 } 2324 $keyword = str_replace(' ', ' ', $keyword); 2325 $keyword_list = explode(' ', $keyword); 2326 2327 for ($i = 0; $i < count($keyword_list); $i++) { 2328 $keyword = check_search_word($keyword_list[$i]); 2329 2330 $wheres[] = 'c_review_comment.body like ?'; 2331 $params[] = '%' . $keyword . '%'; 2332 } 2333 } 2334 2335 if ($wheres) { 2336 $where = ' WHERE ' . implode(' AND ', $wheres); 2337 } else { 2338 $where = ''; 2291 2339 } 2292 2340 -
OpenPNE/trunk/webapp_biz/modules/biz/lib/mysql_functions.php
r4231 r4272 374 374 //keywordあり 375 375 if ($keyword) { 376 $where = ' WHERE true AND (info LIKE ? OR name LIKE ?)ORDER BY biz_group_id';376 $where = ' WHERE info LIKE ? OR name LIKE ? ORDER BY biz_group_id'; 377 377 $sql = 'SELECT * FROM biz_group'. $where; 378 378 … … 534 534 $contain = array(); 535 535 536 $sql = 'SELECT biz_schedule_id FROM biz_schedule WHERE true AND(begin_date LIKE \''.$y.'-'.$m.'%\' OR finish_date LIKE \''.$y.'-'.$m.'%\') AND begin_date != finish_date';536 $sql = 'SELECT biz_schedule_id FROM biz_schedule WHERE (begin_date LIKE \''.$y.'-'.$m.'%\' OR finish_date LIKE \''.$y.'-'.$m.'%\') AND begin_date != finish_date'; 537 537 $tmp = db_get_all($sql, $params); 538 538
Note: See TracChangeset
for help on using the changeset viewer.