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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Data Model Questions /

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

Tell me whats wrong with this query?


Go to End


3 Posts   1399 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