Jump to:

22977 Posts in 11806 Topics by 2826 members

General Questions

SilverStripe Forums » General Questions » setting a dataobject filter dynamically

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

Page: 1
Go to End
Author Topic: 325 Views
  • lozhowlett
    Avatar
    Community Member
    140 Posts

    setting a dataobject filter dynamically Link to this post

    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!

  • lozhowlett
    Avatar
    Community Member
    140 Posts

    Re: setting a dataobject filter dynamically Link to this post

    found the answer...

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

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