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

Does anyone have some examples of DataObject::get and $many_many relationship


Go to End


19 Posts   11996 Views

Avatar
NickJacobs

Community Member, 148 Posts

18 February 2010 at 5:16pm

Edited: 18/02/2010 5:17pm

thanks for that.....now, one more :)

is there any way of getting just one (random) DataObject through this method?

ie can you pass anything else to $theSection->Banners("BannerType = '$bannerType'");

Avatar
bummzack

Community Member, 904 Posts

18 February 2010 at 8:55pm

Yes, you can.
If I remember correctly it's:
WHERE, SORT, JOIN, LIMIT

To get one random Banner you could call:

$theSection->Banners("BannerType = '$bannerType'", 'RAND()', '', '1');

Avatar
Wolfbane

Community Member, 5 Posts

29 November 2011 at 10:14pm

Just wanted to say that I continue to be blown away by how awesome Silverstripe is.. I'm running in circles trying to get some DataObjects all working together and then with a quick search I find out that I literally need to code up:

		$d = $cat->Businesses(); 

Just.. wow :)

Thanks!

Go to Top