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

DataObject::get and child classes


Go to End


2 Posts   1512 Views

Avatar
DesignCollective

Community Member, 66 Posts

30 September 2011 at 12:23pm

I am planning on developing a few child classes from a parent one. I noticed in SiteTree if I do a DataObject::get search for a page class, it will also return all child classes.

How does Silverstripe track ID's on child classes? Are all child class objects tracked in the parent table, too (by ID), or would I need to be careful e.g. a ChildClass starts from 1 and and a ChildClass with ID=1 may not be the same object as ParentClass ID=1?

Hope this makes sense.

Avatar
Willr

Forum Moderator, 5523 Posts

30 September 2011 at 10:53pm

Subclasses keep the exact same ID as parent classes. So if you get a ID on SubsubPage it'll be the same ID as SubPage, Page, SiteTree.