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.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

General Questions /

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

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

setting a dataobject filter dynamically


Go to End


2 Posts   704 Views

Avatar
lozhowlett

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

1 November 2011 at 3:24am

found the answer...

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