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   749 Views

Avatar
nicanor

Community Member, 15 Posts

9 August 2011 at 11:12pm

Edited: 10/08/2011 12:54am

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

Community Member, 15 Posts

10 August 2011 at 12:52am

Edited: 10/08/2011 12:53am

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

Community Member, 15 Posts

10 August 2011 at 10:29am

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.