The Doctrine Documentation has this code:
<?php // update_product.php <id> <new-name> require_once "bootstrap.php"; $id = $argv[1]; $newName = $argv[2]; $product = $entityManager->find('Product', $id); if ($product === null) { echo "Product $id does not exist.\n"; exit(1); } $product->setName($newName); $entityManager->flush();
What I don't understand is the last part, where after setting the product name using $product->setName() , the $entityManager->flush() method is called:
$product->setName($newName); $entityManager->flush();
It seems to me that there is no connection between the $product variable and the $entityManager variable, except for the fact that $product must contain the response from the $entityManager->find() method.
How is it possible that $entityManager->flush() can read the values ββset by $product->setName() ?
source share