CREATE PROCEDURE [dv_list]
@boardid int=1,
@pagenow int=1, --当前页数
@pagesize int=1, --定义每页面帖子数目
@tl int=0, --按时间段查询
@topicmode int=0, --专题
@totalrec int output
AS
set nocount on
declare @int_topnum int
declare @int_timenum int
declare @var_times varchar(5000)
if @pagenow>1
if @topicmode>0
begin
select @int_timenum=(@pagenow-1)*@pagesize
set rowcount @int_timenum
select @var_times=lastposttime from Dv_Topic where boardID=@boardID and istop = 0 and mode=@topicmode ORDER BY lastposttime desc
set rowcount @pagesize
select TopicID,boardid,title,postusername,postuserid,dateandtime,child,hits,votetotal,lastpost,lastposttime,istop,isvote,isbest,locktopic,Expression,TopicMode,Mode from dv_topic where boardID=@boardID and istop = 0 and mode=@topicmode and lastposttime < @var_times ORDER BY lastposttime desc
set nocount off
return
end
else
begin
select @int_timenum=(@pagenow-1)*@pagesize
set rowcount @int_timenum
select @var_times=lastposttime from Dv_Topic where boardID=@boardID and istop = 0 ORDER BY lastposttime desc
set rowcount @pagesize
select TopicID,boardid,title,postusername,postuserid,dateandtime,child,hits,votetotal,lastpost,lastposttime,istop,isvote,isbest,locktopic,Expression,TopicMode,Mode from dv_topic where boardID=@boardID and istop = 0 and lastposttime < @var_times ORDER BY lastposttime desc
set nocount off
return
end
else
if @topicmode>0
begin
set rowcount @pagesize
select TopicID,boardid,title,postusername,postuserid,dateandtime,child,hits,votetotal,lastpost,lastposttime,istop,isvote,isbest,locktopic,Expression,TopicMode,Mode from Dv_topic where boardID=@boardid and istop = 0 and mode=@topicmode ORDER BY lastposttime desc
end
else
begin
set rowcount @pagesize
select TopicID,boardid,title,postusername,postuserid,dateandtime,child,hits,votetotal,lastpost,lastposttime,istop,isvote,isbest,locktopic,Expression,TopicMode,Mode from Dv_topic where boardID=@boardid and istop = 0 ORDER BY lastposttime desc
end
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO