cs_forums_Thread_Get
ALTER PROCEDURE [dbo].cs_forums_Thread_Get
/**//*
Procedure for getting basic information on a single thread.
为获取单个主题的基本信息
*/
(
@ThreadID int,
@UserID int,
@SettingsID int
) AS
SET Transaction Isolation Level Read UNCOMMITTED
/**//*设置事务隔离级别,Read UNCOMMITTED 执行脏读或 0 级隔离锁定,这表示不发出共享锁,
也不接受排它锁。当设置该选项时,可以对数据执行未提交读或脏读;在事务结束前可以更
改数据内的数值,行也可以出现在数据集中或从数据集消失。该选项的作用与在事务内所有
语句中的所有表上设置 NOLOCK 相同。这是四个隔离级别中限制最小的级别。*/
SELECT
T.*,
P.PostID,
P.Subject,
P.Body,P.FormattedBody,
P.PostConfiguration,
P.PropertyNames as PostPropertyNames,
P.PropertyValues as PostPropertyValues,
UserName = T.PostAuthor,
HasRead = CASE
WHEN @UserID = 0 THEN 0
WHEN @UserID > 0 THEN (Select Convert(bit,Count(*)) FROM cs_vw_HasReadForum where ((ThreadID is null and MarkReadAfter > p.ThreadID) or (MarkReadAfter is null and ThreadID = p.ThreadID)) and UserID = @UserID and SectionID = p.SectionID)
END
FROM
cs_Posts P,
cs_Threads T,
cs_vw_Users_FullUser U
WHERE
P.PostID = P.ParentID AND
P.ThreadID = @ThreadID AND
T.ThreadID = P.ThreadID AND
P.UserID = U.cs_UserID and P.SettingsID = @SettingsID
ALTER PROCEDURE [dbo].cs_forums_Thread_Get
/**//*
Procedure for getting basic information on a single thread.
为获取单个主题的基本信息
*/
(
@ThreadID int,
@UserID int,
@SettingsID int
) AS
SET Transaction Isolation Level Read UNCOMMITTED
/**//*设置事务隔离级别,Read UNCOMMITTED 执行脏读或 0 级隔离锁定,这表示不发出共享锁,
也不接受排它锁。当设置该选项时,可以对数据执行未提交读或脏读;在事务结束前可以更
改数据内的数值,行也可以出现在数据集中或从数据集消失。该选项的作用与在事务内所有
语句中的所有表上设置 NOLOCK 相同。这是四个隔离级别中限制最小的级别。*/
SELECT
T.*,
P.PostID,
P.Subject,
P.Body,P.FormattedBody,
P.PostConfiguration,
P.PropertyNames as PostPropertyNames,
P.PropertyValues as PostPropertyValues,
UserName = T.PostAuthor,
HasRead = CASE
WHEN @UserID = 0 THEN 0
WHEN @UserID > 0 THEN (Select Convert(bit,Count(*)) FROM cs_vw_HasReadForum where ((ThreadID is null and MarkReadAfter > p.ThreadID) or (MarkReadAfter is null and ThreadID = p.ThreadID)) and UserID = @UserID and SectionID = p.SectionID)
END
FROM
cs_Posts P,
cs_Threads T,
cs_vw_Users_FullUser U
WHERE
P.PostID = P.ParentID AND
P.ThreadID = @ThreadID AND
T.ThreadID = P.ThreadID AND
P.UserID = U.cs_UserID and P.SettingsID = @SettingsID
cs_forums_Posts_PostSet_RSSThreadless
ALTER PROCEDURE dbo.cs_forums_Posts_PostSet_RSSThreadless
(
@PageSize int,
@SectionID int,
@SettingsID int
)
AS
SET Transaction Isolation Level Read UNCOMMITTED
/**//*设置事务隔离级别,Read UNCOMMITTED 执行脏读或 0 级隔离锁定,这表示不发出共享锁,
也不接受排它锁。当设置该选项时,可以对数据执行未提交读或脏读;在事务结束前可以更
改数据内的数值,行也可以出现在数据集中或从数据集消失。该选项的作用与在事务内所有
语句中的所有表上设置 NOLOCK 相同。这是四个隔离级别中限制最小的级别。*/
BEGIN
-- First set the rowcount
-- 首先设置行数记数
SET ROWCOUNT @PageSize
-- Select the individual posts
--查询个人帖子
SELECT
P.PostID, P.ThreadID, P.ParentID, P.PostAuthor, P.UserID, P.SectionID, P.PostLevel, P.SortOrder, P.Subject, P.PostDate, P.IsApproved,
P.IsLocked, P.IsIndexed, P.TotalViews, P.Body, P.FormattedBody, P.IPAddress, P.PostType, P.EmoticonID, P.SettingsID, P.AggViews,
P.PropertyNames as PostPropertyNames, P.PropertyValues as PostPropertyValues,
P.PostConfiguration, P.UserTime, P.ApplicationPostType, P.PostName,
P.Points as PostPoints,
T.*, U.*,
T.IsLocked,
T.IsSticky,
Username = P.PostAuthor,
ThreadStarterAuthor = T.PostAuthor,
ThreadStartDate = T.PostDate,
EditNotes = (SELECT EditNotes FROM cs_PostEditNotes WHERE PostID = P.PostID),
AttachmentFilename = ISNULL ( (SELECT [FileName] FROM cs_PostAttachments WHERE PostID = P.PostID), ''),
Replies = 0, --not used(SELECT COUNT(P2.PostID) FROM cs_Posts P2 (nolock) WHERE P2.ParentID = P.PostID AND P2.PostLevel != 1),
IsModerator = 0, -- not used
HasRead = 0 -- not used
FROM
cs_Posts P (nolock),
cs_Threads T,
cs_vw_Users_FullUser U
WHERE
P.UserID = U.cs_UserID AND
T.ThreadID = P.ThreadID AND
T.SectionID = @SectionID AND
P.IsApproved = 1 AND
P.SettingsID = @SettingsID
ORDER BY
P.PostDate DESC
END
/**//*从用户信息视图和帖子表\主题表中查询*/
ALTER PROCEDURE dbo.cs_forums_Posts_PostSet_RSSThreadless
(
@PageSize int,
@SectionID int,
@SettingsID int
)
AS
SET Transaction Isolation Level Read UNCOMMITTED
/**//*设置事务隔离级别,Read UNCOMMITTED 执行脏读或 0 级隔离锁定,这表示不发出共享锁,
也不接受排它锁。当设置该选项时,可以对数据执行未提交读或脏读;在事务结束前可以更
改数据内的数值,行也可以出现在数据集中或从数据集消失。该选项的作用与在事务内所有
语句中的所有表上设置 NOLOCK 相同。这是四个隔离级别中限制最小的级别。*/
BEGIN
-- First set the rowcount
-- 首先设置行数记数
SET ROWCOUNT @PageSize
-- Select the individual posts
--查询个人帖子
SELECT
P.PostID, P.ThreadID, P.ParentID, P.PostAuthor, P.UserID, P.SectionID, P.PostLevel, P.SortOrder, P.Subject, P.PostDate, P.IsApproved,
P.IsLocked, P.IsIndexed, P.TotalViews, P.Body, P.FormattedBody, P.IPAddress, P.PostType, P.EmoticonID, P.SettingsID, P.AggViews,
P.PropertyNames as PostPropertyNames, P.PropertyValues as PostPropertyValues,
P.PostConfiguration, P.UserTime, P.ApplicationPostType, P.PostName,
P.Points as PostPoints,
T.*, U.*,
T.IsLocked,
T.IsSticky,
Username = P.PostAuthor,
ThreadStarterAuthor = T.PostAuthor,
ThreadStartDate = T.PostDate,
EditNotes = (SELECT EditNotes FROM cs_PostEditNotes WHERE PostID = P.PostID),
AttachmentFilename = ISNULL ( (SELECT [FileName] FROM cs_PostAttachments WHERE PostID = P.PostID), ''),
Replies = 0, --not used(SELECT COUNT(P2.PostID) FROM cs_Posts P2 (nolock) WHERE P2.ParentID = P.PostID AND P2.PostLevel != 1),
IsModerator = 0, -- not used
HasRead = 0 -- not used
FROM
cs_Posts P (nolock),
cs_Threads T,
cs_vw_Users_FullUser U
WHERE
P.UserID = U.cs_UserID AND
T.ThreadID = P.ThreadID AND
T.SectionID = @SectionID AND
P.IsApproved = 1 AND
P.SettingsID = @SettingsID
ORDER BY
P.PostDate DESC
END
/**//*从用户信息视图和帖子表\主题表中查询*/