Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Forum Module

Discuss the Forum Module.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

[Solved] db error for Forum RSS feed (SS 2.3.4 and forum 0.2.4)


Reply

4 Posts   2469 Views

Avatar
Bruce B

1 December 2009 at 1:29pm (Last edited: 3 December 2009 7:37pm), Community Member, 145 Posts

After upgrading both SS and the forum module, I'm getting the following error repeatedly. Any suggestions?

Couldn't run query: SELECT max(ID) as LastID, max(Created) as LastCreated FROM Post JOIN SiteTree_Live ForumPage on POST.ForumID=ForumPage.ID WHERE ForumPage.ParentID=48 Column 'ID' in field list is ambiguous
Line 401 of MySQLDatabase.php
MySQLDatabase->databaseError(Couldn't run query: SELECT max(ID) as LastID, max(Created) as LastCreated FROM Post JOIN SiteTree_Live ForumPage on POST.ForumID=ForumPage.ID WHERE ForumPage.ParentID=48 | Column 'ID' in field list is ambiguous,256)
Line 102 of MySQLDatabase.php
MySQLDatabase->query(SELECT max(ID) as LastID, max(Created) as LastCreated FROM Post JOIN SiteTree_Live ForumPage on POST.ForumID=ForumPage.ID WHERE ForumPage.ParentID=48,256)
Line 120 of DB.php
DB::query(SELECT max(ID) as LastID, max(Created) as LastCreated FROM Post JOIN SiteTree_Live ForumPage on POST.ForumID=ForumPage.ID WHERE ForumPage.ParentID=48)
Line 559 of ForumHolder.php
ForumHolder_Controller->NewPostsAvailable(,,Array)
Line 467 of ForumHolder.php
ForumHolder_Controller->rss(HTTPRequest)
Line 159 of Controller.php
Controller->handleAction(HTTPRequest)
Line 129 of RequestHandler.php
RequestHandler->handleRequest(HTTPRequest)
Line 119 of Controller.php
Controller->handleRequest(HTTPRequest)
Line 29 of ModelAsController.php
ModelAsController->handleRequest(HTTPRequest)
Line 277 of Director.php
Director::handleRequest(HTTPRequest,Session)
Line 121 of Director.php
Director::direct(/wamboin-noticeboards/rss)
Line 118 of main.php

Avatar
Bruce B

3 December 2009 at 7:37pm Community Member, 145 Posts

I'll have to write this one up as a bug in Forum 0.2.4, I think. For this site I have created a number of fields in the basic Page so I have Page, Page_Live and Page_versions tables. This means the field ID need to be written as `Post`.ID to avoid the ambiguous field error message. A couple of other fields have the same problem so line 558 of ForumHolder.php becomes:

$version = DB::query("SELECT max(`Post`.ID) as LastID, max(`Post`.Created) " .
"as LastCreated FROM Post JOIN " . ForumHolder::baseForumTable() . " ForumPage on `Post`.ForumID=ForumPage.ID WHERE ForumPage.ParentID={$this->ID}")->first();

which fixes the problem.

Avatar
Willr

3 December 2009 at 8:15pm Forum Moderator, 5511 Posts

It is a bug in 0.2.4 but was fixed in trunk recently - http://open.silverstripe.org/changeset/93489/modules/forum/trunk/code

Avatar
WalterW

9 March 2010 at 9:19pm Community Member, 18 Posts

There is another ambiguity! I get following DB error message:

# Couldn't run query: SELECT `Post`.*, `Post`.ID, if(`Post`.ClassName,`Post`.ClassName,'Post') AS RecordClassName FROM `Post` JOIN SiteTree_Live ForumPage on Post.ForumID=ForumPage.ID WHERE (TopicID > 0 AND ID > 389 AND ForumPage.ParentID='69') GROUP BY `Post`.ID ORDER BY Created DESC LIMIT 50 Column 'ID' in where clause is ambiguous
Line 401 of MySQLDatabase.php
# MySQLDatabase->databaseError(Couldn't run query: SELECT `Post`.*, `Post`.ID, if(`Post`.ClassName,`Post`.ClassName,'Post') AS RecordClassName FROM `Post` JOIN SiteTree_Live ForumPage on Post.ForumID=ForumPage.ID WHERE (TopicID > 0 AND ID > 389 AND ForumPage.ParentID='69') GROUP BY `Post`.ID ORDER BY Created DESC LIMIT 50 | Column 'ID' in where clause is ambiguous,256)
Line 102 of MySQLDatabase.php
# MySQLDatabase->query(SELECT `Post`.*, `Post`.ID, if(`Post`.ClassName,`Post`.ClassName,'Post') AS RecordClassName FROM `Post` JOIN SiteTree_Live ForumPage on Post.ForumID=ForumPage.ID WHERE (TopicID > 0 AND ID > 389 AND ForumPage.ParentID='69') GROUP BY `Post`.ID ORDER BY Created DESC LIMIT 50,256)
Line 120 of DB.php

I changed the function RecentPosts

      if($lastPostID > 0)
         $filter .= " AND ID > $lastPostID";


to

      if($lastPostID > 0)
         $filter .= " AND Post.ID > $lastPostID";

Should be corrected!