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

Do relations to a class work with the classes children?


Go to End


3 Posts   1376 Views

Avatar
baba-papa

Community Member, 279 Posts

7 March 2010 at 2:45am

I do have a 1:1 relation between a class Auction and a class Product.

static $has_one = array("product"=>"Product")

I intend to subclass Product for many different product categories, eg Shoe extends Product, Belt extends Product.
Would I have to define a new relation if I want a relation between Auction and Shoe?

Avatar
Willr

Forum Moderator, 5523 Posts

7 March 2010 at 7:49pm

No you won't have to create a new relation. If shoe is a subclass of product then shoe is still a product and has a product record. So should work fine.

Avatar
baba-papa

Community Member, 279 Posts

7 March 2010 at 8:20pm

Thanks again, willr.