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.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

SSBits - Working with Banners || SS 2.4.2 Issue?

Go to End

5 Posts   1275 Views

iON creative

Community Member, 42 Posts

3 November 2010 at 10:03am

I have used the code provided at the SSBits site for a number of my Silverstripe sites with no problems whatsoever:

However the first time I've attempted to use the OneRandomBanner function with 2.4.2 I'm getting the following error:

[User Error] Couldn't run query: SELECT "File"."ClassName", "File"."Created", "File"."LastEdited", "File"."Name", "File"."Title", "File"."Filename", "File"."Content", "File"."Sort", "File"."SortOrder", "File"."ParentID", "File"."OwnerID", "File"."ID", CASE WHEN "File"."ClassName" IS NOT NULL THEN "File"."ClassName" ELSE 'File' END AS "RecordClassName" FROM "File" WHERE ("File"."ClassName" IN ('Image','Image_Cached')) AND (ClassName "Folder" AND ParentID = SELECT ID FROM File WHERE ClassName = "Folder" AND Name = "Headers")) ORDER BY RAND() LIMIT 5 Unknown column 'Folder' in 'where clause'

This is a first - and the column 'Folder' is present.

Can anyone advise on this issue?

Many thanks,


Forum Moderator, 1899 Posts

3 November 2010 at 10:35am

Edited: 03/11/2010 11:24am

clearly there is an '=' missing...

... AND (ClassName "Folder" AND ...

EDIT I take it back after looking at the article, that states it supports for 2.4, it's a '<>' that is missing... unless ss is failing to show that in the error message...


Community Member, 473 Posts

3 November 2010 at 10:39am

The code was written for SS 2.3, which didn't use ANSI SQL. String literals need to be enclosed by single quotes rather than double quotes, as double quotes denotes a table or (as is the case here) column. You need to replace all occurrences of "Folder" with 'Folder'.

iON creative

Community Member, 42 Posts

3 November 2010 at 11:28am

Thanks - that is the case (ie the <> are there in my function, but not in the error message).

iON creative

Community Member, 42 Posts

3 November 2010 at 11:36am

Update - changing the quotes has removed the SQL error - thanks!

However nothing is returned to the template for the function call, despite the existence of the directory and images within it.