ここの情報は古いです。ご理解頂いた上でお取り扱いください。

Changeset 3588


Ignore:
Timestamp:
Jul 31, 2007, 9:13:41 PM (12 years ago)
Author:
ebihara
Message:

#1003:検索語にマッチしたc_topic_commentの最新日時で降順ソートするように変更

File:
1 edited

Legend:

Unmodified
Added
Removed
  • OpenPNE/trunk/webapp/lib/db/commu.php

    r3482 r3588  
    27932793{
    27942794    $select = 'SELECT c.name AS commu_name, c.image_filename AS commu_image'
    2795             . ', ct.*, MAX(ctc2.r_datetime) AS last_datetime, MAX(ctc2.number) as max_number';
    2796     $from = ' FROM c_commu AS c, c_commu_topic AS ct, c_commu_topic_comment AS ctc, c_commu_topic_comment AS ctc2';
     2795            . ', ct.*, ctc.r_datetime';
     2796    $from = ' FROM c_commu AS c, c_commu_topic AS ct, c_commu_topic_comment AS ctc';
    27972797
    27982798    $params = array();
    27992799    $where = ' WHERE ct.c_commu_topic_id = ctc.c_commu_topic_id'
    2800            . ' AND ct.c_commu_topic_id = ctc2.c_commu_topic_id'
    28012800           . ' AND c.c_commu_id = ct.c_commu_id';
    28022801    if ($c_commu_id) {
     
    28282827    }
    28292828    $group = ' GROUP BY ct.c_commu_topic_id';
    2830     $order = ' ORDER BY last_datetime DESC';
     2829    $order = ' ORDER BY ctc.r_datetime DESC';
    28312830
    28322831    $sql = $select . $from . $where . $group . $order;
    28332832    $list = db_get_all_page($sql, $page, $page_size, $params);
    2834    
     2833
    28352834    foreach ($list as $key => $value) {
    28362835        $p = array((int)$value['c_commu_topic_id']);
    28372836        $sql = 'SELECT body FROM c_commu_topic_comment WHERE number = 0 AND c_commu_topic_id = ?';
    28382837        $list[$key]['body'] = db_get_one($sql, $p);
     2838        $sql = 'SELECT MAX(number) FROM c_commu_topic_comment WHERE c_commu_topic_id = ?';
     2839        $list[$key]['max_number'] = db_get_one($sql, $p);
     2840        $sql = 'SELECT MAX(r_datetime) FROM c_commu_topic_comment WHERE c_commu_topic_id = ?';
     2841        $list[$key]['last_datetime'] = db_get_one($sql, $p);
    28392842    }
    28402843
Note: See TracChangeset for help on using the changeset viewer.