break; case 'fromme': $sql .= " and t.authorid = '{$_G[uid]}'"; break; case 'replyme': $navtitle = '回复我的'; if ($r_tids = C::t('feed_reply')->fetch_all_tids_by_ruid($_G['uid'])) { $sql .= " and t.tid IN (" . dimplode($r_tids) . ")"; } else { $sql .= " and 0"; } dsetcookie('feed_readtime_replyme', $_G['timestamp'], 60 * 60 * 24 * 7); break; case 'all': $navtitle = '全部动态'; $sql .= " and readperm='0'"; $orderby = ' order by t.top DESC,t.lastpost DESC'; break; } $count = DB::result_first("select COUNT(*) from " . DB::table('feed_thread') . " t LEFT JOIN " . DB::table('feed_post') . " p on p.tid=t.tid where {$sql} "); $threads = DB::fetch_all("select t.*,p.message,p.useip,p.pid from " . DB::table('feed_thread') . " t LEFT JOIN " . DB::table('feed_post') . " p on p.tid=t.tid where {$sql} {$orderby} limit {$start},{$perpage}"); $list = array(); foreach ($threads as $value) { $value['iscollect'] = DB::result_first("select COUNT(*) from %t where uid=%d and tid=%d", array('feed_collection', $_G['uid'], $value['tid'])); $value['message'] = dzzcode($value['message']); $value['attachs'] = C::t('feed_attach')->fetch_all_by_pid($value['pid']); $value['dateline'] = dgmdate($value['dateline'], 'u'); $list[$value['tid']] = $value; } $multi = multi($count, $perpage, $page, $theurl, 'pull-right'); include template('feed');
public function fetch_all_by_pcid($pcid, $limit, $iscount = false) { $limitsql = ''; if ($limit) { $limit = explode('-', $limit); if (count($limit) > 1) { $limitsql .= " limit " . intval($limit[0]) . "," . intval($limit[1]); } else { $limitsql .= " limit " . intval($limit[0]); } } if ($iscount) { return DB::result_first("select COUNT(*) from %t where pcid=%d ", array($this->_table, $pcid)); } $data = array(); foreach (DB::fetch_all("select * from %t where pcid=%d order by dateline DESC {$limitsql}", array($this->_table, $pcid)) as $value) { $value['message'] = dzzcode($value['message']); $value['dateline'] = dgmdate($value['dateline'], 'u'); $value['attachs'] = C::t('comment_attach')->fetch_all_by_cid($value['cid']); if ($value['rcid']) { $value['rpost'] = parent::fetch($value['rcid']); } $data[] = $value; } return $data; }