Jump to:

3459 Posts in 1064 Topics by 739 members

Data Model Questions

SilverStripe Forums » Data Model Questions » DataObject::get() returns NULL when no records are found?

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

Page: 1
Go to End
Author Topic: 447 Views
  • GuillaumeC
    Avatar
    Community Member
    5 Posts

    DataObject::get() returns NULL when no records are found? Link to this post

    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!

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