Changeset 6640
- Timestamp:
- Apr 18, 2008, 11:40:37 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
OpenPNE/trunk/webapp/lib/db/commu.php
r6632 r6640 515 515 $is_recurred = false; 516 516 517 if ($GLOBALS['_OPENPNE_DSN_LIST']['main']['dsn']['phptype'] == 'pgsql') { 518 $sql = "SELECT cct.c_commu_topic_id , cct.name, MAX(cctc.r_datetime) as r_datetime , cct.c_commu_id" . 519 " , max(cctc.image_filename1) as image_filename1, max(cctc.image_filename2) as image_filename2, max(cctc.image_filename3) as image_filename3 " . 520 " FROM c_commu_topic_comment as cctc , c_commu_topic as cct" . 521 " WHERE cctc.c_commu_topic_id = cct.c_commu_topic_id " . 522 " AND cct.event_flag = ?". 523 " AND cct.c_commu_id = ?". 524 " group by cct.c_commu_topic_id, cct.name, cct.c_commu_id " . 525 " order by r_datetime desc "; 526 } else { 527 $sql = "SELECT c_commu_topic_id , name, u_datetime as r_datetime , c_commu_id " . 528 " FROM c_commu_topic" . 529 " WHERE event_flag = ? AND c_commu_id = ?". 530 " order by r_datetime desc "; 531 } 517 $sql = "SELECT c_commu_topic_id , name, u_datetime as r_datetime , c_commu_id " . 518 " FROM c_commu_topic" . 519 " WHERE event_flag = ? AND c_commu_id = ?". 520 " ORDER BY r_datetime DESC"; 532 521 $params = array((bool)$event_flag, intval($c_commu_id)); 533 522 $list = db_get_all_limit($sql, 0, $limit, $params); … … 826 815 827 816 $hint = db_mysql_hint('USE INDEX (r_datetime_c_commu_id)'); 828 if ($GLOBALS['_OPENPNE_DSN_LIST']['main']['dsn']['phptype'] == 'pgsql') { 829 $sql = 'SELECT sub_cct_tbl.c_commu_topic_id, cct.c_commu_id, sub_cct_tbl.r_datetime, cct.c_member_id'. 830 ' FROM (' . 831 ' SELECT cct.c_commu_topic_id, MAX(cctc.r_datetime) as r_datetime' . 832 ' FROM' . 833 ' c_commu_topic as cct, c_commu_topic_comment as cctc'. $hint . 834 ' WHERE ' . 835 ' cct.c_commu_id IN (' . $ids . ') AND cctc.c_commu_topic_id = cct.c_commu_topic_id'. 836 ' GROUP BY cct.c_commu_topic_id' . 837 ') as sub_cct_tbl, c_commu_topic_comment as cctc , c_commu_topic as cct' . 838 ' WHERE' . 839 ' cct.c_commu_topic_id=sub_cct_tbl.c_commu_topic_id' . 840 ' AND cctc.c_commu_topic_id = cct.c_commu_topic_id ' . 841 ' AND cctc.r_datetime=sub_cct_tbl.r_datetime' . 842 ' ORDER BY r_datetime DESC'; 843 $params = array(); 844 } else { 845 $sql = 'SELECT a.c_commu_topic_id, a.c_commu_id, a.u_datetime as r_datetime, a.c_member_id,'. 846 ' a.name as c_commu_topic_name'. 847 ' FROM c_commu_topic as a INNER JOIN c_commu_member as b USING(c_commu_id)'. 848 ' WHERE b.c_member_id = ?'. 849 ' ORDER BY r_datetime DESC'; 850 $params = array(intval($c_member_id)); 851 } 817 $sql = 'SELECT a.c_commu_topic_id, a.c_commu_id, a.u_datetime as r_datetime, a.c_member_id,'. 818 ' a.name as c_commu_topic_name'. 819 ' FROM c_commu_topic as a INNER JOIN c_commu_member as b USING(c_commu_id)'. 820 ' WHERE b.c_member_id = ?'. 821 ' ORDER BY r_datetime DESC'; 822 $params = array(intval($c_member_id)); 852 823 $c_commu_topic_list = db_get_all_limit($sql, 0, $limit, $params); 853 824 … … 884 855 885 856 $hint = db_mysql_hint('USE INDEX (r_datetime_c_commu_id)'); 886 if ($GLOBALS['_OPENPNE_DSN_LIST']['main']['dsn']['phptype'] == 'pgsql') { 887 $sql = 'SELECT sub_cct_tbl.c_commu_topic_id, cct.c_commu_id, sub_cct_tbl.r_datetime, cct.c_member_id'. 888 ' FROM (' . 889 ' SELECT cct.c_commu_topic_id, MAX(cctc.r_datetime) as r_datetime' . 890 ' FROM' . 891 ' c_commu_topic as cct, c_commu_topic_comment as cctc'. $hint . 892 ' WHERE ' . 893 ' cct.c_commu_id IN (' . $ids . ') AND cctc.c_commu_topic_id = cct.c_commu_topic_id'. 894 ' GROUP BY cct.c_commu_topic_id' . 895 ') as sub_cct_tbl, c_commu_topic_comment as cctc , c_commu_topic as cct' . 896 ' WHERE' . 897 ' cct.c_commu_topic_id=sub_cct_tbl.c_commu_topic_id' . 898 ' AND cctc.c_commu_topic_id = cct.c_commu_topic_id ' . 899 ' AND cctc.r_datetime=sub_cct_tbl.r_datetime' . 900 ' ORDER BY r_datetime DESC'; 901 $params = array(); 902 } else { 903 $sql = 'SELECT a.c_commu_topic_id, a.c_commu_id, a.u_datetime as r_datetime, a.c_member_id,'. 904 ' a.name as c_commu_topic_name'. 905 ' FROM c_commu_topic as a INNER JOIN c_commu_member as b USING(c_commu_id)'. 906 ' WHERE b.c_member_id = ?'. 907 ' ORDER BY r_datetime DESC'; 908 $params = array(intval($c_member_id)); 909 } 857 $sql = 'SELECT a.c_commu_topic_id, a.c_commu_id, a.u_datetime as r_datetime, a.c_member_id,'. 858 ' a.name as c_commu_topic_name'. 859 ' FROM c_commu_topic as a INNER JOIN c_commu_member as b USING(c_commu_id)'. 860 ' WHERE b.c_member_id = ?'. 861 ' ORDER BY r_datetime DESC'; 862 $params = array(intval($c_member_id)); 910 863 $c_commu_topic_list = db_get_all_limit($sql, ($page-1)*$limit, $limit, $params); 911 864
Note: See TracChangeset
for help on using the changeset viewer.