Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDNN Open Source...DNN Open Source...Module ForumsModule ForumsForumForum[Forum_Thread_GetAll] Stored Procedure[Forum_Thread_GetAll] Stored Procedure
Previous
 
Next
New Post
6/30/2008 6:00 AM
 

Hi,

I was looking at the Forum Database structure and found this Stored Procedure.

This was very strnge to NOTE that there has been a condition check where you checked for Thread Existense based on :

FP.PostID = T.ThreadID

The above text was taken from the Dynamic SQL generated Inside this Stored Procedure: [Forum_Thread_GetAll]

Actual full content is this:

-- Create dynamic SQL to populate temporary table   
    SELECT  @sql = 'INSERT INTO #PageIndex (ThreadID)' + ' SELECT T.ThreadID' + ' FROM {databaseOwner}{objectQualifier}Forum_Threads T' + ' WHERE T.ThreadID IN' +
'   (SELECT TOP ' + CONVERT(VARCHAR, @PageSize) + ' T.ThreadID' + '     FROM {databaseOwner}{objectQualifier}Forum_Threads T' +
'     INNER JOIN {databaseOwner}{objectQualifier}Forum_Posts FP ON T.ThreadID = FP.ThreadID' + '     INNER JOIN {databaseOwner}{objectQualifier}Forum_Posts LP ON T.ThreadID = LP.ThreadID' +
'     INNER JOIN {databaseOwner}{objectQualifier}Forum_Forums F ON T.ForumID = F.ForumID' + '     INNER JOIN {databaseOwner}{objectQualifier}Forum_Groups FG ON F.GroupID = FG.GroupID' +
'     WHERE FG.ModuleID = ' + CONVERT(VARCHAR, @ModuleID) + '     AND (T.ForumID = ' + CONVERT(VARCHAR, @ForumID) + ' OR (' + CONVERT(VARCHAR, @ForumID) + ' = -1 AND F.PublicView = 1 AND T.IsPinned = 0))' +
'     AND LP.PostID = T.LastPostedPostID AND FP.PostID = T.ThreadID' +
'     AND (FP.IsApproved = 1)  AND (FP.IsLocked = 0) ' + @Filter + '     AND T.ThreadID NOT IN' +
'       (SELECT TOP ' + CONVERT(VARCHAR, @PageLowerBound) + ' T.ThreadID' +
'          FROM {databaseOwner}{objectQualifier}Forum_Threads T' +
'          INNER JOIN {databaseOwner}{objectQualifier}Forum_Posts FP ON T.ThreadID = FP.ThreadID' +
'          INNER JOIN {databaseOwner}{objectQualifier}Forum_Posts LP ON T.ThreadID = LP.ThreadID' +
'          INNER JOIN {databaseOwner}{objectQualifier}Forum_Forums F ON T.ForumID = F.ForumID' +
'          INNER JOIN {databaseOwner}{objectQualifier}Forum_Groups FG ON F.GroupID = FG.GroupID' +
'          WHERE FG.ModuleID = ' + CONVERT(VARCHAR, @ModuleID) +
'          AND (T.ForumID = ' + CONVERT(VARCHAR, @ForumID) + ' OR (' + CONVERT(VARCHAR, @ForumID) + ' = -1 AND F.PublicView = 1 AND T.IsPinned = 0))' +
'          AND LP.PostID = T.LastPostedPostID AND FP.PostID = T.ThreadID' +
'          AND (FP.IsApproved = 1)  AND (FP.IsLocked = 0) ' + @Filter +
'          ORDER BY T.IsPinned DESC, LP.CreatedDate DESC)' + ' ORDER BY T.IsPinned DESC, LP.CreatedDate DESC)'
    EXEC ( @sql )

Please guide me why this Check has been placed I'm really unable to understand that. Don't you think it should be this: FP.ThreadID = T.ThreadID

 

Thanks.

 
New Post
6/30/2008 2:11 PM
Accepted Answer 

ah .. I got it ... you are distinguishing First post as Thread as well as Post and thus PostID is Same as ThreadID. So that means, each Thread is a Post too. Sorry took me long to catch that :).

 
Previous
 
Next
HomeHomeDNN Open Source...DNN Open Source...Module ForumsModule ForumsForumForum[Forum_Thread_GetAll] Stored Procedure[Forum_Thread_GetAll] Stored Procedure


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out