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.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Multiple DataObject::get in one function


Reply


2 Posts   1937 Views

Avatar
markuse

Community Member, 4 Posts

9 September 2009 at 9:16am

Edited: 12/09/2009 2:51am

Dear all,
I have a function "MyFunction" from where I can call two different objects. Each on its own work fine, I get either "Result A" or "Result B". Both getManyManyComponents() from both DataObject::get are calling the same class.

So Result A and result B have a common subset of results. Is there a simple way to combine two DataObject::get?
Thank for your help

class DoResults_Controller extends Page_Controller {
function MyFunction(){
....
//$result = DataObject::get("TheOneObject","TheOneFilter");//Result A
$result = DataObject::get("TheOtherObject","TheOtherFilter");//Result B
return $result;
}
...
}

class TheOneObject extends DataObject {
....
static $belongs_many_many = array(
'Topics' => 'Topic'
);
function GetThisOne(){
return $this->getManyManyComponents("Topics");
}
}

class TheOtherObject extends DataObject {
....
static $belongs_many_many = array(
'Topics' => 'Topic'
);

function GetTheOtherOne(){
return $this->getManyManyComponents("Topics");
}
}

Avatar
B-Side

Community Member, 42 Posts

3 June 2010 at 6:47pm

Hi there - I was wondering if you worked out a solution to this issue? I have the same question!

Cheers, Jayne