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:

Data Model Questions /

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

Tell me whats wrong with this query?


Go to End


3 Posts   1108 Views

Avatar
Jakxnz

Community Member, 36 Posts

14 December 2009 at 11:22pm

Hey guys,

A quick post, hopefully you can point me in the right direction.


$QueryTag = 'New Article';
$RelatedArticles = DataObject::get('ArticleManagerArticle','`ArticleManagerArticle`.`Title` = \''.$QueryTag.'\'');
//Returns ArticleManagerArticle->Title = "New Article"

$QueryTag = '%Article%';
$RelatedArticles = DataObject::get('ArticleManagerArticle','`ArticleManagerArticle`.`Title` = \''.$QueryTag.'\'');
//Returns nothing

I would have expected that the Query would have easily pulled the "New Article" title again?

The application for this is just to call related articles to a Sidebar.

Avatar
Willr

Forum Moderator, 5523 Posts

15 December 2009 at 9:13am

Try using `ArticleManagerArticle`.`Title` LIKE '%Article%' (Or LIKE '%Article') rather then the =.

Avatar
Jakxnz

Community Member, 36 Posts

16 December 2009 at 11:05pm

Worked. Cheers :D