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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

setting a dataobject filter dynamically


Reply


2 Posts   425 Views

Avatar
lozhowlett

Community Member, 146 Posts

1 November 2011 at 2:35am

Hi everyone

I am trying to do this...

$filter = 'NumberOfBeds >= '&& $minbeds &&' AND maxprice < ' && $maxprice && ' AND minprice > ' && $minprice;

However when I debug it, it just says filter is a bool=none value?!?

Am I doing something really stupid?

function PropertySearchResults() {
$minbeds = Session::get('minbeds');
$maxprice = Session::get('maxprice');
$minprice = Session::get('minprice');
$filter = 'NumberOfBeds >= '&& $minbeds &&' AND maxprice < ' && $maxprice && ' AND minprice > ' && $minprice;
Debug::show($filter);
$properties = DataObject::get('PropertyDetail',$filter);

return $properties;
}

Thanks!

Avatar
lozhowlett

Community Member, 146 Posts

1 November 2011 at 3:24am

found the answer...

$properties = DataObject::get('PropertyDetail',"NumberOfBeds >= " . $minbeds . " AND RentPerMonth < " . $maxprice . " AND RentPerMonth > " . $minprice);