Symfony 5: Mastering Doctrine Relations
Saving Items in a ManyToMany Relation
  Start your All-Access Pass to unlock this challenge
Buy Access Login

Challenge 1 / 1

I have a Product entity that is a ManyToMany to Distributor. Imagine that the $distributor, $product1 and $product2 objects have already been saved to the database:

$distributor->addProduct($product1);
$entityManager->flush();

$distributor->addProduct($product1);
$distributor->addProduct($product2);
$entityManager->flush();

$distributor->removeProduct($product1);
$entityManager->flush();

After running this code, how many rows are in the product_distributor table?

Skip challenges and go to theNext Chapter

Turn Challenges Off?

All further challenges will be skipped automatically.
You can re-enable challenges at any time on this page or from your account page.