Jump to:

3433 Posts in 1058 Topics by 734 members

Data Model Questions

SilverStripe Forums » Data Model Questions » Tell me whats wrong with this query?

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

Page: 1
Go to End
Author Topic: 782 Views
  • jdi
    Avatar
    Community Member
    34 Posts

    Tell me whats wrong with this query? Link to this post

    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.

  • Willr
    Avatar
    Forum Moderator
    5490 Posts

    Re: Tell me whats wrong with this query? Link to this post

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

  • jdi
    Avatar
    Community Member
    34 Posts

    Re: Tell me whats wrong with this query? Link to this post

    Worked. Cheers

    782 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.