【数据结构与算法】bbs的数据结构和存储过程(三)

更新时间:2019-09-04 来源:热门资讯 点击:

【www.hzclsc.cn--热门资讯】

/*************************************************************************/

/* */

/* 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

as



/*定义局部变量*/

declare @intRootID int

declare @intLayer int

declare @floatOrderNum float(53)

declare @floatNextOrderNum float(53)

declare @intCounts int

declare @intForumID int



/*取消计数*/

set nocount on



/*首先查找这个贴子的rootid和ordernum,没有则返回*/

select @intRootID = RootID ,

@floatOrderNum = OrderNum ,

@intLayer = layer ,

@intForumID = forumid

from bbs where id = @a_intTopicID

if @@rowcount = 0

return (-1)



/*取下一个同层贴子的ordernum*/

select @FloatNextOrderNum = isnull(max(ordernum) , 0)

from bbs

where RootID=@intRootID

and layer=@intLayer and ordernum @floatNextOrderNum

and ordernum @m_intPoint



select * , "order" = @m_intOrder from bbsuser where username=@a_strUserName



set nocount off

go

up_getuserinfo "廖家远"



/*************************************************************************/

/* */

/* procedure : up_PostedTopic */

/* */

/* Description: 将贴子转入精华区 */

/* */

/* Parameters: @a_intTopicID 贴子id */

/* */

/* Use table: bbs, postedtopic */

/* */

/* Author: bigeagle@163.net */

/* */

/* Date: 2000/4/17 */

/* */

/* History: */

/* */

/*************************************************************************/



if exists(select * from sysobjects where id= object_id("up_postedtopic"))

drop proc up_postedtopic

go



create proc up_PostedTopic @a_intTopicID int

as

/*定义局部变量*/

declare @m_intUserID int --发贴人ID



/*查找是否有这个贴子*/

select @m_intUserID = userid from bbs where id = @a_intTopicID

if(@@rowcount != 1)

return -1



/*因为对两个表操作所以用事务*/

begin transaction

update bbs set posted = 1 where id = @a_intTopicID

if(@@error 0)

goto Error

update bbsuser set point = point + 3 where id = @m_intUserID

if(@@error 0)

goto Error

Commit transaction

return (0)

Error:

rollback transaction

go






本文来源:http://www.hzclsc.cn/news/26347.html

为您推荐

dnf鬼泣新buff换装|dnf鬼泣BUFF换装如何搭配 dnf起源版鬼泣BUFF换装搭配攻略

您的位置:首页 → 网游资讯 → dnf资讯 → dnf鬼泣BUFF换装如何搭配 dnf起源版鬼泣BUFF换装搭配攻略 dnf鬼泣BUFF换装如何搭配 dnf起源版鬼泣BUFF换装搭配攻略时间:201dnf资讯

2021-02-25 18:54:41   dnf鬼泣buff换装95   地下城鬼泣buff换装  

dnf流年鬼泣装备_dnf鬼泣起源版本装备搭配推荐 dnf黑暗君主起源版本加点攻略

2月1日DNF起源版本正式更新了,这次更新全职业平衡性将进行调整,所以这个版本DNF黑暗君主起源版本怎么加点?DNF黑暗君主起源版本用什么装备好?下面小编为大家爱带来了DNF黑暗君主起源版本加点攻略dnf资讯

2021-02-25 18:54:41   dnf鬼泣装备推荐   dnf鬼泣毕业装备  

【dnf黄金雄鹰图腾怎么升级】dnf黄金雄鹰图腾怎么得 黄金雄鹰图腾出现概率介绍

DNF游戏中成功建造传说图腾的小伙伴可以一次性拿到20个图腾精华,而普通的和特殊也才只给到6个,是普通 特殊的3倍还多,难怪这么多的玩家追求黄金雄鹰图腾了,毕竟有了它,组合出传说的概率非常的高。 为dnf资讯

2021-02-25 18:54:41  

[dnf起源剧情]dnf起源版本公会改动一览 dnf起源版本公会有哪些变动

全新的起源版本已经到来,这次改版的改动很大,甚至有些小伙伴都在游戏中迷路了,那么在全新的起源版本中公会有哪些变化呢?下面就让我们一起去了解一下DNF起源版本公会改动吧! DNF起源版本公会改动一览起dnf资讯

2021-02-25 18:54:41  

德特尔兽人族|dnf兽人族的特别宝物礼盒有什么 兽人族的特别宝物礼盒选择建议

兽人族的特别宝物礼盒打开后,可以在两种宝物礼盒中选择一种,远古兽人族的神秘宝物礼盒、兽人族英雄的宝珠礼盒,很多小伙伴不知道怎么选择才好,小编今天带来一篇DNF兽人族的特别宝物礼盒选择建议,希望大家喜dnf资讯

2021-02-25 18:54:41   怪物猎人世界老练的兽人族学者   兽人族永不为奴除非