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.

Data Model Questions /

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


Go to End
Reply


19 Posts   8069 Views

Avatar
NickJacobs

Community Member, 144 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
banal

Community Member, 901 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