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.

General Questions /

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

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

SSBits - Working with Banners || SS 2.4.2 Issue?


Reply


5 Posts   968 Views

Avatar
B-Side

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:
http://www.ssbits.com/tutorials/2009/working-with-banners/

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,
Jayne

Avatar
swaiba

Forum Moderator, 1808 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...

Avatar
simon_w

Forum Moderator, 474 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'.

Avatar
B-Side

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).

Avatar
B-Side

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.

Suggestions?