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

add wher clause in latest news


Reply

2 Posts   1025 Views

Avatar
bebabeba

23 October 2009 at 7:54pm Community Member, 192 Posts

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

Avatar
banal

23 October 2009 at 8:02pm Community Member, 901 Posts

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;
}