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.

Blog Module

Discuss the Blog Module.

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

[SOLVED]Pull latest blog post except the one that is currently viewed. Please Help.


18 Posts   2234 Views


12 February 2013 at 9:36pm Forum Moderator, 5511 Posts

Ok didn't know that was a decorators. In decorators you have to use $this->owner to get the object they 'decorate' so in your case use - $this->owner->ID


12 February 2013 at 9:52pm Community Member, 18 Posts

[User Error] Couldn't run query: SELECT "SiteTree_Live"."ClassName", "SiteTree_Live"."Created", "SiteTree_Live"."LastEdited", "SiteTree_Live"."URLSegment", "SiteTree_Live"."Title", "SiteTree_Live"."MenuTitle", "SiteTree_Live"."Content", "SiteTree_Live"."MetaTitle", "SiteTree_Live"."MetaDescription", "SiteTree_Live"."MetaKeywords", "SiteTree_Live"."ExtraMeta", "SiteTree_Live"."ShowInMenus", "SiteTree_Live"."ShowInSearch", "SiteTree_Live"."HomepageForDomain", "SiteTree_Live"."ProvideComments", "SiteTree_Live"."Sort", "SiteTree_Live"."HasBrokenFile", "SiteTree_Live"."HasBrokenLink", "SiteTree_Live"."Status", "SiteTree_Live"."ReportClass", "SiteTree_Live"."CanViewType", "SiteTree_Live"."CanEditType", "SiteTree_Live"."ToDo", "SiteTree_Live"."Version", "SiteTree_Live"."Priority", "SiteTree_Live"."ChangeFreq", "SiteTree_Live"."ShowSideAd", "SiteTree_Live"."ShowBannerAd", "SiteTree_Live"."DisplayTitle", "SiteTree_Live"."ShowSidebar", "SiteTree_Live"."ParentID", "Page_Live"."Access", "Page_Live"."MenuColumns", "Page_Live"."Feature", "Page_Live"."Description", "BlogEntry_Live"."Date", "BlogEntry_Live"."Author", "BlogEntry_Live"."Tags", "BlogEntry_Live"."ImageID", "SiteTree_Live"."ID", CASE WHEN "SiteTree_Live"."ClassName" IS NOT NULL THEN "SiteTree_Live"."ClassName" ELSE 'SiteTree' END AS "RecordClassName" FROM "SiteTree_Live" LEFT JOIN "Page_Live" ON "Page_Live"."ID" = "SiteTree_Live"."ID" LEFT JOIN "BlogEntry_Live" ON "BlogEntry_Live"."ID" = "SiteTree_Live"."ID" WHERE ("SiteTree_Live"."ClassName" IN ('BlogEntry')) AND (ParentID IN(584,736,50) AND ID != 736) ORDER BY Date DESC LIMIT 10 Column 'ID' in where clause is ambiguous
GET /FA2/western-conference-semi-finals?flush=1

Line 525 in C:\xampp\htdocs\FA2\sapphire\core\model\MySQLDatabase.php

i got this new error, what sould i do?


12 February 2013 at 10:55pm (Last edited: 12 February 2013 10:57pm), Community Member, 243 Posts

Hey Juan, this might help


12 February 2013 at 11:02pm (Last edited: 12 February 2013 11:06pm), Community Member, 11 Posts

Hi Juan,

I'll explain your problem here and how to fix it specific to SilverStripe and SQL.

Behind the scenes when you call DataObject::get, lots of joins happen. Because the same column name is sometimes shared between lots of tables, the SQL engine doesn't know which table's column you're referring to if there's two of them.

Luckily, SilverStripe handles this for you easily. In this instance all you need to to do is change this:

$posts = DataObject::get('BlogEntry','ParentID IN('.$idList.') AND ID != '. (int) $postID,'Date DESC','',$limit);

In to this:

$posts = DataObject::get('BlogEntry','ParentID IN('.$idList.') AND "BlogEntry".ID != '. (int) $postID,'Date DESC','',$limit);

Notice how I've added "BlogEntry". at the front of the ID? This tells SilverStripe's ORM that you're specifically talking about BlogEntries, not any of the related tables needed to build your data model.

While everyone's up for helping with even the simplest problem, it's safe to say that everyone would also be really grateful if you took the time to try a few things yourself: [url=]What Have You Tried?[/url]


12 February 2013 at 11:36pm Community Member, 18 Posts

hello avengex,

it didn't work.. its still displaying on the list..

im planing unset the array

foreach($idArr as $key => $newvalue) {
if(stripos($newvalue, $postID) !== false){


$newidList = implode(',',$idArr);

and use this

$posts = DataObject::get('BlogEntry','ParentID IN('.$newidList .')','Date DESC','',$limit);

do you think its gonna work?


13 February 2013 at 12:16am Community Member, 11 Posts

What do you think is going wrong?


13 February 2013 at 4:08pm Community Member, 18 Posts

i think we're getting the wrong postID i also did a query in mysql there is no 736 ID in blogentry_live table. :|

(ParentID IN(584,736,50) AND BlogEntry.ID != 736)


13 February 2013 at 6:31pm Community Member, 18 Posts

i am correct we're getting the wrong postID

when i try to test this line below.. i am getting the correct results..

$posts = DataObject::get('BlogEntry','ParentID IN('.$idList.') AND "BlogEntry"."ID" != '. (int) 2259,'Date DESC','',$limit);

how should i correct this, $this->owner->ID so that i can get the ID of the selected post?