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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Data Model Questions /

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

How to merge two DataObjectSets

Go to End

3 Posts   2351 Views


Community Member, 116 Posts

16 April 2010 at 9:25am

Edited: 16/04/2010 9:26am

Hey guys,

Really simple one here. I'm wondering if one can take two DataObjectSets (from two separate DataObject::get requests) and join them together.

I have two different DataObjects, Module.php and Course.php. I want to call both of them using one function, so I can order both Modules AND Courses by Title ASC using a control block.

Currently the code I have is:

function Modules(){
return DataObject::get("Module");

function Courses(){
return DataObject::get("Course");

Can I do what i'm trying to achieve in it's own function? Or can I reference the above functions in another function to achieve the join?



Community Member, 11 Posts

17 August 2010 at 5:01am

I have the same doubt.


Forum Moderator, 1899 Posts

17 August 2010 at 9:01am

how about...

function Composite()
	$dosComposite = new DataObjectSet();
	return $dosComposite;