Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Options

LastCommentID

edited May 2009 in Vanilla 1.0 Help
Wondering if this is possible - I'm terrible at SqlBuilder.

I'm using the RSS2 add-on but would like to return in the join the most recent comment rather than the first comment. At present the code joins the first comment obviously based on the FirstCommentID field in the Discussion table like this:

function DiscussionManager_GetFirstCommentForRSS2($DiscussionManager) { $SqlBuilder = &$DiscussionManager->DelegateParameters['SqlBuilder']; $SqlBuilder->AddJoin('Comment', 'fc', 'CommentID', 't', 'FirstCommentID', 'left join'); $SqlBuilder->AddSelect(array('FormatType', 'Body'), 'fc'); }

How can this be tweaked to join the latest Comment content in that discussion rather than the first? I'm assuming its a sub query but I'm lost.

thanks for any help

Comments

  • Options
    MarkMark Vanilla Staff
    Untested code below. Use at your own risk:
    function DiscussionManager_GetFirstCommentForRSS2($DiscussionManager) { $SqlBuilder = &$DiscussionManager->DelegateParameters['SqlBuilder']; $SqlBuilder->AddJoin('Comment', 'lc', 'CommentID', 't', 'LastCommentID', 'left join'); $SqlBuilder->AddSelect(array('FormatType', 'Body'), 'lc'); }
  • Options
    edited April 2009
    Thanks Mark, doesn't seem to work, but there isn't a LastCommentID field in the Discussion table to join on is there? Or has there been a table change between 1.1.5a to 1.1.6?
  • Options
    edited May 2009
    Seriously, can this not be done? Can a subquery say like:

    SELECT CommentID FROM `LUM_Comment` WHERE DiscussionID = XXX ORDER BY DateCreated DESC LIMIT 1
    not be used to get the LastCommentID and then joined to the Discussion Manager? Mark seems to be referring to a 'LastCommentID' but I don't see that existing anywhere like 'FirstCommentID' exists in the Discussion table...?

    Confused.
Sign In or Register to comment.