Hi All
This may be simple but im just not sure
I have a dataobject extension that has a function with a query in it, i want to access that function from a different dataobject extension.
Can this be done? and how?
Thanks
This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.
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.
Hi All
This may be simple but im just not sure
I have a dataobject extension that has a function with a query in it, i want to access that function from a different dataobject extension.
Can this be done? and how?
Thanks
Create it as a static function:
Class MyDataObject extends DataObject {
public static function foo() {
// Do some querying
}
}
You can then call it by doing:
MyDataObject::foo()
Hi Kinglozzer
Thanks for your reply, when i made the function public static the wheels came off a bit and nothing worked.
although this gives me something to go on unfortunatly i have little time to explore this right now so i will plug away as i get time and try a few things and see what i get working
thanks again
voodoochile
If it's static you need to refer to the extension classname (e.g MyDataExtension::foo()). If your method is instance based you need to go $this->owner->foo().
Thanks Willr
I managed to work that bit out as in MyDataExtension::foo() and kind of got it working but not well, in the page view it returns a value for each object but dosn't seem to be running the query.
at this point i think i need to play around a little with this to get the result i am looking for.