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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Data Model Questions /

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

DataObject::get() returns NULL when no records are found?


Go to End


1150 Views

Avatar
gcoderre

Community Member, 5 Posts

16 January 2012 at 10:35am

Edited: 17/01/2012 12:42am

Hi everyone,

I'm not sure I fully understand all the inners of DataObject yet, but I'm surprised to see that executing DataObject::get() with a filter that returns no record returns nothing, rather than an empty DataObjectSet. Is this normal?

Example:


// assuming that the database contains no record which Date > CURDATE()

$news_articles = DataObject::get("NewsArticle", "Date > CURDATE()");
return $news_articles; // This returns NULL.

Thanks for your help!