Jump to:

3433 Posts in 1058 Topics by 734 members

Data Model Questions

SilverStripe Forums » Data Model Questions » CanHas_One Relation

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

Page: 1
Go to End
Author Topic: 360 Views
  • melatonin
    Avatar
    Community Member
    6 Posts

    CanHas_One Relation Link to this post

    Hi i am searching on a nullable has_one relation.
    What is the solution to realize it?

    Thank you.

  • melatonin
    Avatar
    Community Member
    6 Posts

    Re: CanHas_One Relation Link to this post

    anybody an idea?

  • swaiba
    Avatar
    Forum Moderator
    1785 Posts

    Re: CanHas_One Relation Link to this post

    Hi melatonin,

    AFAIK the has_one Relationship will populated with 0, not NULL.
    But if you want to identify this with SQL, specifically MySQL, you can use...

    SELECT * FROM MyTable WHERE MyField IS NULL;
    OR
    SELECT * FROM MyTable WHERE COALESCE(MyField,0) = 0

    (COALESCE means it goes through all param left to right and returns the first param that is NOT NULL)

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