bbs的数据结构和存储过程(三)

2016-01-29 17:33 2 1 收藏

bbs的数据结构和存储过程(三),bbs的数据结构和存储过程(三)

【 tulaoshi.com - ASP 】

  /*************************************************************************/
/* */
/* procedure : up_GetPostedTopicList */
/* */
/* Description: 精华区贴子列表 */
/* */
/* Parameters: @a_intForumID : 版面id */
/* @a_intPageNo: 页号 */
/* @a_intPageSize: 每页显示数,以根贴为准 */
/* */
/* Use table: bbs , forum */
/* */
/* Author: bigeagle@163.net */
/* */
/* Date: 2000/2/14 */
/* */
/* History: */
/* */
/*************************************************************************/
if exists(select * from sysobjects where id = object_id('up_GetPostedTopicList'))
drop proc up_GetPostedTopicList
go

create proc up_GetPostedTopicList
@a_intForumID int ,
@a_intPageNo int ,
@a_intPageSize int
as
/*定义局部变量*/
declare @intBeginID int
declare @intEndID int
declare @intRootRecordCount int
declare @intPageCount int
declare @intRowCount int
/*关闭计数*/
set nocount on

/*检测是否有这个版面*/
if not exists(select * from forum where id = @a_intForumID)
return (-1)

/*求总共根贴数*/
select @intRootRecordCount = count(*) from bbs where posted=1 and forumid=@a_intForumID
if (@intRootRecordCount = 0) --如果没有贴子,则返回零
return 0

/*判断页数是否正确*/
if (@a_intPageNo - 1) * @a_intPageSize @intRootRecordCount
return (-1)

/*求开始rootID*/
set @intRowCount = (@a_intPageNo - 1) * @a_intPageSize + 1
/*限制条数*/
set rowcount @intRowCount
select @intBeginID = rootid from bbs where posted=1 and forumid=@a_intForumID
order by id desc

/*结束rootID*/
set @intRowCount = @a_intPageNo * @a_intPageSize
/*限制条数*/
set rowcount @intRowCount
select @intEndID = rootid from bbs where posted=1 and forumid=@a_intForumID
order by id desc

/*恢复系统变量*/
set rowcount 0
set nocount off

select a.id , a.layer , a.forumid , a.subject , a.faceid , a.hits , a.time , a.UserID , a.fatherid , a.rootid ,
'Bytes' = datalength(a.content) , b.UserName , b.Email , b.HomePage , b.Signature , b.Point
from bbs as a join BBSUser as b on a.UserID = b.ID
where posted=1 and Forumid=@a_intForumID and a.rootid between @intEndID and @intBeginID
order by a.rootid desc , a.ordernum desc
return(@@rowcount)
--select @@rowcount
go
select id , rootid , fatherid , forumid , posted from bbs
up_getpostedtopiclist 3 ,1 , 20
/*************************************************************************/
/* */
/* procedure : up_GetTopic */
/* */
/* Description: 取贴子 */
/* */
/* Parameters: @a_intTopicID : 贴子id */
/* */
/* Use table: bbs */
/* */
/* Author: bigeagle@163.net */
/* */
/* Date: 2000/2/16 */
/* */
/* History: */
/* */
/*************************************************************************/
if exists(select * from sysobjects where id = object_id('up_GetTopic'))
drop proc up_GetTopic
go

create proc up_GetTopic @a_intTopicID int
as
/*如果没有这贴子*/
if not exists (select * from bbs where id = @a_intTopicID)
return (-1)

/*更新该贴的点击数*/
update bbs set hits = hits + 1 where id = @a_intTopicID

select a.* , 'Bytes' = datalength(a.content) ,
b.UserName , b.Email , b.Homepage , b.point , b.Signature
from bbs as a join BBSUser as b on a.UserID = b.id
where a.id = @a_intTopicID
go

up_getTopic 11

/*************************************************************************/
/* */
/* procedure : up_DeleTopic */
/* */
/* Description: 删除贴子及子贴,更新发贴人信息 */
/* */
/* Parameters: @a_intTopicID : 贴子id */
/* */
/* Use table: bbs */
/* */
/* Author: bigeagle@163.net */
/* */
/* Date: 2000/2/24 */
/* */
/* History: */
/* */
/*************************************************************************/

if exists(select * from sysobjects where id = object_id('up_DeleTopic'))
drop proc up_DeleTopic
go

create proc up_DeleTopic @a_intTopicID int

来源:https://www.tulaoshi.com/n/20160129/1501874.html

延伸阅读
栈和队列是操作受限的线性表,似乎每本讲数据结构的数都是这么说的。有些书按照这个思路给出了定义和实现;但是很遗憾,本文没有这样做,所以,有些书中的做法是重复建设,这或许可以用不是一个人写的这样的理由来开脱。 顺序表示的栈和队列,必须预先分配空间,并且空间大小受限,使用起来限制比较多。而且,由于限定存取位置,...
  第十五章 Linux核心数据结构 本章列出了Linux实用的主要数据结构。 block_dev_struct 此结构用于向核心登记块设备,它还被buffer cache实用。所有此类结构都位于blk_dev数组中。 struct blk_dev_struct { void (*request_fn)(void); struct request * current_request; struct reque...
标签: ASP
  【bigeagle】 于 2000-12-6 14:45:13 加贴在 Joy ASP ↑: 下面这种方法是white提出来的。 BBS数据库结构的浮点数表示法 BBS由一系列的文章组成,每篇文章有一些基本属性,比如作者,创建时间,文章编号等。其中最为重要的,用以表示树形结构的是层和序数。层表示位于文章树的第几层,最高层的帖子层等于0,其回复的层为1,回复的回...
#includestdio.h #includestdlib.h #includestring.h #includeconio.ha #includegraphics.h #define MAXVALUE 200           /*权值的最大值*/ #define MAXB99v  30             /*最大的编码位...
递归法和回溯法 有人说,回溯实际上是递归的展开,但实际上。两者的指导思想并不一致。 !-- frame contents -- !-- /frame contents -- 打个比方吧,递归法好比是一个军队要通过一个迷宫,到了第一个分岔口,有3条路,将军命令3个小队分别去探哪条路能到出口,3个小队沿着3条路分别前进,各自到达了路...