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

ManyManyList addMany


Go to End


928 Views

Avatar
ismooth

Community Member, 25 Posts

17 July 2014 at 12:07am

Edited: 17/07/2014 12:09am

Hi,
I have following code:

$pendingReviewers = new DataList('Member');
foreach ($reviews as $rev) {
	$temp = $rev->getManyManyComponents('Reviewers','ReviewerStatus = 0');
	Debug::dump($temp->count());
	$pendingReviewers->addMany($temp);
	Debug::dump($pendingReviewers->count());
}

What is interesting about this is that the two dumps don't produce the same output (but they should since I am testing this on one Dataobject). First one produces 0, while second outputs 1 (correct is 0). Why is this?

A quick look at the getManyManyComponents method makes me think that filtering is done at a too late stage, and is actually done on a wrong classmodel. I'd really appreciate a comment from someone more sure of this.

Furthermore, I've tried filtering these results in various ways using DataList, but with no luck. Only way I could've solved this is when using ArrayList and then pushing data to the list, but this is not satisfying for me cause query execution occurs too early (since there can be many reviews).