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

DataObject::get greaterThan


Reply

3 Posts   722 Views

Avatar
nicanor

9 August 2011 at 11:12pm (Last edited: 10 August 2011 12:54am), Community Member, 15 Posts

DataObject::get("PersonPage",
          "TipNr < 1",
          "",
       "",
       "");

works fine and I get all entries where no number is set and the field is default 0.

DataObject::get("PersonPage",
          "TipNr > 1",
          "",
       "",
       "");

and

DataObject::get("PersonPage",
          "TipNr != 1",
          "",
       "",
       "");

don't work. I get no result. Is it not possible to use sql "greaterThan" or "isNot" in the Where-clause?

Avatar
nicanor

10 August 2011 at 12:52am (Last edited: 10 August 2011 12:53am), Community Member, 15 Posts

I just saw that

DataObject::get("PersonPage",
"TipNr < 1",
"",
"",
"");


gives back a result but the boolean lower than is not interpreted.

e.g.

DataObject::get("PersonPage",
"TipNr < 5",
"",
"",
"");


gives back the same result inculded records with tipNr 7,8 ...

So i thinck it's not possible to use lessthan,greaterthan or isNot with DataObject::get and i have to do it with sqlquery. is it right?

Avatar
nicanor

10 August 2011 at 10:29am Community Member, 15 Posts

The failure was that i tried a DataObject::get with an object that inherits from a Page. It's not possible to filter Page Objects like above. When the the Object inherits from DataObject evrything works

extends Page

vs.

extends DataObject.

Solved.