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

CanHas_One Relation


Go to End


3 Posts   1352 Views

Avatar
melatonin

Community Member, 6 Posts

25 March 2014 at 2:53am

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

Thank you.

Avatar
melatonin

Community Member, 6 Posts

29 March 2014 at 2:01am

anybody an idea?

Avatar
swaiba

Forum Moderator, 1899 Posts

2 April 2014 at 4:33am

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)