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.

Data Model Questions /

Tell me whats wrong with this query?


Reply


3 Posts   846 Views

Avatar
jdi

Community Member, 34 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, 5513 Posts

15 December 2009 at 9:13am

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

Avatar
jdi

Community Member, 34 Posts

16 December 2009 at 11:05pm

Worked. Cheers :D