7912 Posts in 1355 Topics by 930 members
DataObjectManager Module
SilverStripe Forums » DataObjectManager Module » Multiple DataObject::get in one function
Discuss the DataObjectManager module, and the related ImageGallery module.
Moderators: martimiz, UncleCheese, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 1712 Views |
-
Multiple DataObject::get in one function

9 September 2009 at 9:16am Last edited: 12 September 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 helpclass 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");
}
} -
Re: Multiple DataObject::get in one function

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
| 1712 Views | ||
|
Page:
1
|
Go to Top |

