您的位置:首页 > 其它

Discuz 论坛 版主回复后在帖子列表后加版主回复字样

2012-07-19 18:07 507 查看
 找到 存储过程 dnt_gettopiclist

ALTER PROCEDURE [dbo].[dnt_gettopiclist]
@fid int,
@pagesize int,
@startnum int,
@pageindex int
AS
DECLARE @strSQL varchar(5000)
if object_id('tempdb..#a') is not null drop table #a --创建临时表
select distinct a.tid,'<font color=red>版主回复</font>' tailtitle into #a
from dnt_posts1 a,dnt_users b where a.posterid=b.uid
and a.fid=@fid and b.groupid<=3--用户组别<=3的

--之后topics 与临时表#a 再做左连接就可以实现了
IF @pageindex = 1
 BEGIN
  SET @strSQL = 'SELECT TOP ' + STR(@pagesize) +' [rate],a.[tid],[iconid],[typeid],[title],b.tailtitle,[price],[hide],[readperm],
[special],[poster],[posterid],[replies],[views],[postdatetime],[lastpost],[lastposter],
[lastpostid],[lastposterid],[replies],[highlight],[digest],[displayorder],[attachment],[closed],[magic],[special] FROM
[dnt_topics] a left join #a b on a.tid=b.tid WHERE [fid]=' +STR(@fid) + ' AND [displayorder]=0  ORDER BY [lastpostid] DESC'
 END
ELSE
 BEGIN
  SET @strSQL = 'SELECT TOP ' + STR(@pagesize) +'[rate], a.[tid],[iconid],[typeid],[title],b.tailtitle,[price],[hide],[readperm],
[special],[poster],[posterid],[replies],[views],[postdatetime],[lastpost],[lastposter],
[lastpostid],[lastposterid],[replies],[highlight],[digest],[displayorder],[attachment],[closed],[magic],[special] FROM
[dnt_topics] a left join #a b on a.tid=b.tid WHERE [lastpostid] < (SELECT min([lastpostid])  FROM (SELECT TOP ' + STR
((@pageindex-1)*@pagesize-@startnum) + ' [lastpostid] FROM [dnt_topics] WHERE [fid]=' +STR
(@fid) + ' AND [displayorder]=0 ORDER BY [lastpostid] DESC) AS tblTmp )
AND [fid]=' +STR(@fid) + ' AND [displayorder]=0 ORDER BY [lastpostid] DESC'
 END
 print @strSQL
EXEC(@strSQL)
 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐