Answer the question
In order to leave comments, you need to log in
Why does flush($some) flush all changes?
Hello, today I encountered the following behavior in symfony:
$remove = $this->getEm()->getRepository('MainBundle:Something')->findOneBy([],['id'=>'ASC']);
$this->getEm()->remove($remove);
$city = new City();
$city->setName(date('U'));
$this->getEm()->persist($city);
$this->getEm()->flush($city);
Answer the question
In order to leave comments, you need to log in
Vitaly Sorokin , Answers here:
https://github.com/doctrine/doctrine2/blob/master/...
https://github.com/doctrine/doctrine2/blob/master/...
/**
* Only flushes the given entity according to a ruleset that keeps the UoW consistent.
*
* 1. All entities scheduled for insertion, (orphan) removals and changes in collections are processed as well!
* 2. Read Only entities are skipped.
* 3. Proxies are skipped.
* 4. Only if entity is properly managed.
*
* @param object $entity
*
* @return void
*
* @throws \InvalidArgumentException
*/
private function computeSingleEntityChangeSet($entity)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question