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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

How to get all records using get()


Go to End


3 Posts   1155 Views

Avatar
Mifas

Community Member, 2 Posts

7 April 2014 at 3:17am

A simple question. In my code

A customer has many partners. If I want to get customer details and a customer have how many partners. What I trying to do is,

$customer = Customer::get();
return Partners::get()->filter('CustomerID', $customer->ID);

Unfortunately above code is not working for me, Is there any easy way to get.?

Avatar
thomas.paulson

Community Member, 107 Posts

7 April 2014 at 2:10pm

this->Partners(); should return all partners; but i am not sure .

Avatar
MichalKleiner

Community Member, 4 Posts

8 April 2014 at 5:35pm

$customer = DataObject::get_by_id('Customer', $customer_id);
return $customer->Partners();