cs_forums_GetUnmoderatedPostStatus
ALTER PROCEDURE [dbo].cs_forums_GetUnmoderatedPostStatus
(
@SectionID int = null,
@UserName varchar,
@SettingsID int
)
AS
SET Transaction Isolation Level Read UNCOMMITTED
/**//*设置事务隔离级别,Read UNCOMMITTED 执行脏读或 0 级隔离锁定,这表示不发出共享锁,
也不接受排它锁。当设置该选项时,可以对数据执行未提交读或脏读;在事务结束前可以更
改数据内的数值,行也可以出现在数据集中或从数据集消失。该选项的作用与在事务内所有
语句中的所有表上设置 NOLOCK 相同。这是四个隔离级别中限制最小的级别。*/
IF(@SectionID = 0)
SET @SectionID = null
IF(@SectionID IS Null)
BEGIN
SELECT OldestPostAgeInMinutes = DateDiff(mi, IsNull(MIN(PostDate),GetDate()),GetDate()),TotalPostsInModerationQueue = Count(PostID)
FROM cs_Posts P
WHERE P.IsApproved = 0
AND P.SettingsID = @SettingsID
/**//*DATEDIFF 返回跨两个指定日期的日期和时间边界数。
ISNULL 使用指定的替换值替换 NULL。 */
END
ELSE
BEGIN
SELECT OldestPostAgeInMinutes = DateDiff(mi, IsNull(MIN(PostDate),GetDate()),GetDate()),TotalPostsInModerationQueue = Count(PostID)
FROM cs_Posts P
WHERE P.IsApproved = 0
AND P.SettingsID = @SettingsID
AND P.SectionID = @SectionID
END
ALTER PROCEDURE [dbo].cs_forums_GetUnmoderatedPostStatus
(
@SectionID int = null,
@UserName varchar,
@SettingsID int
)
AS
SET Transaction Isolation Level Read UNCOMMITTED
/**//*设置事务隔离级别,Read UNCOMMITTED 执行脏读或 0 级隔离锁定,这表示不发出共享锁,
也不接受排它锁。当设置该选项时,可以对数据执行未提交读或脏读;在事务结束前可以更
改数据内的数值,行也可以出现在数据集中或从数据集消失。该选项的作用与在事务内所有
语句中的所有表上设置 NOLOCK 相同。这是四个隔离级别中限制最小的级别。*/
IF(@SectionID = 0)
SET @SectionID = null
IF(@SectionID IS Null)
BEGIN
SELECT OldestPostAgeInMinutes = DateDiff(mi, IsNull(MIN(PostDate),GetDate()),GetDate()),TotalPostsInModerationQueue = Count(PostID)
FROM cs_Posts P
WHERE P.IsApproved = 0
AND P.SettingsID = @SettingsID
/**//*DATEDIFF 返回跨两个指定日期的日期和时间边界数。
ISNULL 使用指定的替换值替换 NULL。 */
END
ELSE
BEGIN
SELECT OldestPostAgeInMinutes = DateDiff(mi, IsNull(MIN(PostDate),GetDate()),GetDate()),TotalPostsInModerationQueue = Count(PostID)
FROM cs_Posts P
WHERE P.IsApproved = 0
AND P.SettingsID = @SettingsID
AND P.SectionID = @SectionID
END
cs_forums_GetForumsModeratedByUser
ALTER procedure [dbo].cs_forums_GetForumsModeratedByUser
(
@UserName nvarchar(50),
@SettingsID int
)
AS
SET Transaction Isolation Level Read UNCOMMITTED
/**//*设置事务隔离级别,Read UNCOMMITTED 执行脏读或 0 级隔离锁定,这表示不发出共享锁,
也不接受排它锁。当设置该选项时,可以对数据执行未提交读或脏读;在事务结束前可以更
改数据内的数值,行也可以出现在数据集中或从数据集消失。该选项的作用与在事务内所有
语句中的所有表上设置 NOLOCK 相同。这是四个隔离级别中限制最小的级别。*/
-- determine if this user can moderate ALL forums
-- 判断此用户是否有权修改全部论
IF EXISTS(SELECT NULL FROM Moderators (nolock) WHERE SectionID = 0 AND Username = @UserName and SettingsID = @SettingsID)
/**//*查询符合条件的含有空值的记录,判断这样的记录是否存在*/
SELECT SectionID, ForumName = 'All Forums', EmailNotification, DateCreated FROM Moderators (nolock)
WHERE SectionID = 0 AND Username = @UserName and SettingsID = @SettingsID
ELSE
-- get all of the forums moderated by this particular user
-- 获取此用户的全部操作
SELECT
M.SectionID,
EmailNotification,
ForumName = F.Name,
M.DateCreated
FROM Moderators M (nolock)
INNER JOIN Forums F (nolock) ON
F.SectionID = M.SectionID
WHERE Username = @UserName and M.SettingsID = @SettingsID and F.SettingsID = @SettingsID
ALTER procedure [dbo].cs_forums_GetForumsModeratedByUser
(
@UserName nvarchar(50),
@SettingsID int
)
AS
SET Transaction Isolation Level Read UNCOMMITTED
/**//*设置事务隔离级别,Read UNCOMMITTED 执行脏读或 0 级隔离锁定,这表示不发出共享锁,
也不接受排它锁。当设置该选项时,可以对数据执行未提交读或脏读;在事务结束前可以更
改数据内的数值,行也可以出现在数据集中或从数据集消失。该选项的作用与在事务内所有
语句中的所有表上设置 NOLOCK 相同。这是四个隔离级别中限制最小的级别。*/
-- determine if this user can moderate ALL forums
-- 判断此用户是否有权修改全部论
IF EXISTS(SELECT NULL FROM Moderators (nolock) WHERE SectionID = 0 AND Username = @UserName and SettingsID = @SettingsID)
/**//*查询符合条件的含有空值的记录,判断这样的记录是否存在*/
SELECT SectionID, ForumName = 'All Forums', EmailNotification, DateCreated FROM Moderators (nolock)
WHERE SectionID = 0 AND Username = @UserName and SettingsID = @SettingsID
ELSE
-- get all of the forums moderated by this particular user
-- 获取此用户的全部操作
SELECT
M.SectionID,
EmailNotification,
ForumName = F.Name,
M.DateCreated
FROM Moderators M (nolock)
INNER JOIN Forums F (nolock) ON
F.SectionID = M.SectionID
WHERE Username = @UserName and M.SettingsID = @SettingsID and F.SettingsID = @SettingsID