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

Changeset 3705


Ignore:
Timestamp:
Aug 14, 2007, 3:13:59 PM (12 years ago)
Author:
ToshihiroK
Message:

postgres対応:トピック検索機能修正対応

File:
1 edited

Legend:

Unmodified
Added
Removed
  • OpenPNE/branches/prj/postgres/2_9_1/webapp/lib/db/commu.php

    r3655 r3705  
    29442944    if ($GLOBALS['_OPENPNE_DSN_LIST']['main']['dsn']['phptype'] == 'pgsql') {
    29452945        $select = 'SELECT distinct on (ct.c_commu_topic_id) c.name AS commu_name, c.image_filename AS commu_image'
    2946                 . ', ct.*, ctc.r_datetime AS r_datetime2';
     2946                . ', ct.*, ctc2.max_datetime';
    29472947    } else {
    29482948        $select = 'SELECT c.name AS commu_name, c.image_filename AS commu_image'
    2949                 . ', ct.*, ctc.r_datetime';
    2950     }
    2951 
    2952     $from = ' FROM c_commu AS c, c_commu_topic AS ct, c_commu_topic_comment AS ctc';
     2949                . ', ct.*, MAX(ctc.r_datetime) AS max_datetime';
     2950    }
     2951
     2952    if ($GLOBALS['_OPENPNE_DSN_LIST']['main']['dsn']['phptype'] == 'pgsql') {
     2953        $from = ' FROM c_commu AS c, c_commu_topic AS ct, c_commu_topic_comment AS ctc';
     2954        $from .= ', (SELECT c_commu_topic_id, max(r_datetime) as max_datetime' .
     2955                    ' FROM c_commu_topic_comment' .
     2956                    ' GROUP BY c_commu_topic_id' .
     2957                    ') AS ctc2';
     2958    } else {
     2959        $from = ' FROM c_commu AS c, c_commu_topic AS ct, c_commu_topic_comment AS ctc';
     2960    }
    29532961
    29542962    $params = array();
    29552963    $where = ' WHERE ct.c_commu_topic_id = ctc.c_commu_topic_id'
    29562964           . ' AND c.c_commu_id = ct.c_commu_id';
     2965   
     2966    if ($GLOBALS['_OPENPNE_DSN_LIST']['main']['dsn']['phptype'] == 'pgsql') {
     2967        $where .= ' AND ct.c_commu_topic_id = ctc2.c_commu_topic_id';
     2968    }
     2969
    29572970    if ($c_commu_id) {
    29582971        $where .= ' AND ct.c_commu_id = ?';
     
    29832996    }
    29842997
     2998    $order = ' ORDER BY max_datetime DESC';
     2999   
    29853000    if ($GLOBALS['_OPENPNE_DSN_LIST']['main']['dsn']['phptype'] == 'pgsql') {
    2986         $order = ' ORDER BY sub_tbl.r_datetime DESC';
    29873001        $sql = "SELECT sub_tbl.* FROM (" . $select . $from . $where . ") as sub_tbl " . $order;
    29883002    } else {
    29893003        $group = ' GROUP BY ct.c_commu_topic_id';
    2990         $order = ' ORDER BY ctc.r_datetime DESC';
    29913004        $sql = $select . $from . $where . $group . $order;
    29923005    }
     
    30003013        $sql = 'SELECT MAX(number) FROM c_commu_topic_comment WHERE c_commu_topic_id = ?';
    30013014        $list[$key]['max_number'] = db_get_one($sql, $p);
    3002         $sql = 'SELECT MAX(r_datetime) FROM c_commu_topic_comment WHERE c_commu_topic_id = ?';
    3003         $list[$key]['last_datetime'] = db_get_one($sql, $p);
    30043015    }
    30053016
Note: See TracChangeset for help on using the changeset viewer.