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


Reply

19 Posts   7949 Views

Avatar
NickJacobs

18 February 2010 at 5:16pm (Last edited: 18 February 2010 5:17pm), Community Member, 144 Posts

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

18 February 2010 at 8:55pm Community Member, 901 Posts

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

29 November 2011 at 10:14pm Community Member, 5 Posts

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!