Jump to:

3372 Posts in 998 Topics by 712 members

Data Model Questions

SilverStripe Forums » Data Model Questions » add wher clause in latest news

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

Page: 1
Go to End
Author Topic: 970 Views
  • bebabeba
    Avatar
    Community Member
    192 Posts

    add wher clause in latest news Link to this post

    Hi!

    I follow guide to show in my home page the last 3 news. Is possible add a where clause to show only news that have in db the field 'type' (I add this field in my db) = economy?

    function LatestNews($num=3) {
    $news = DataObject::get_one("NewsHolder");
    return ($news) ? DataObject::get("NewsPage", "ParentID = $news->ID", "Date DESC", "", $num) : false;
    }

    help please..

  • banal
    Avatar
    Community Member
    901 Posts

    Re: add wher clause in latest news Link to this post

    Something like this should work:

    function LatestNews($num=3) {
       $news = DataObject::get_one("NewsHolder");
       return ($news) ? DataObject::get("NewsPage", "ParentID = $news->ID AND type = 'economy'", "Date DESC", "", $num) : false;
    }

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