Exemplo n.º 1
0
function paper_get_unread_papers($user_id)
{
    global $tablePreStr;
    global $dbServs;
    $dbo = new dbex();
    $t_comments = $tablePreStr . "comments";
    $t_papers = $tablePreStr . "papers";
    dbtarget('r', $dbServs);
    $data = array();
    if (null == $user_id) {
        return $data;
    }
    $datasql = "select {$t_papers}.* from {$t_papers} where {$t_papers}.paper_id in \n(select distinct {$t_comments}.paper_id as unread_count from {$t_comments} \n\twhere (({$t_comments}.paper_id in (select {$t_papers}.paper_id from {$t_papers} where {$t_papers}.user_id = {$user_id}) and {$t_comments}.comment_type=1) \n\t\t\t or ({$t_comments}.commenter_id=1 and {$t_comments}.comment_type=2)) \n\t\tand {$t_comments}.comment_status = 0)";
    $data = $dbo->getAll($datasql);
    return $data;
}