Jump to:

3373 Posts in 998 Topics by 712 members

Data Model Questions

SilverStripe Forums » Data Model Questions » Getting DataObjects with NULL values

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

Page: 1
Go to End
Author Topic: 558 Views
  • NicolasLeuenberger
    Avatar
    Community Member
    9 Posts

    Getting DataObjects with NULL values Link to this post

    Hi dear community

    One of my models is an event (AgendaEintrag) with a DateField. If no date is set, the MySQL-Entry contains the value NULL. Now I'd like to display all Events without a date. This does not work:

    $agendaEintraege = DataObject::get("AgendaEintrag", "Date=NULL", "Date ASC");

    If I search for anything else, it works. I can for example display past events:

    $agendaEintraege = DataObject::get("AgendaEintrag", "Date=<CURDATE()", "Date ASC");

    Any idea how I can get those NULL containing entries? Thanks

  • swaiba
    Avatar
    Forum Moderator
    1769 Posts

    Re: Getting DataObjects with NULL values Link to this post

    how about "Date IS NULL" I think that is how MYSQL does it

  • NicolasLeuenberger
    Avatar
    Community Member
    9 Posts

    Re: Getting DataObjects with NULL values Link to this post

    Jackpot!

    Wow, that was fast and the perfect answer. Thanks so much

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