Herman, Just to clarify my understanding, any I create a new instance of a class it needs to be persist($anInstance_of_a_class). But any time it is retrieved via and $enitityManager->find*() or loaded when being loaded by the found object, it is not need?
If you add another instance of a class to an already managed is it automatically included it the UnitOfWork or do you have explicitly persist($it)? Roy On Mar 9, 2014 12:29 PM, "Herman Peeren" <[email protected]> wrote: > On Sunday, 9 March 2014 20:13:38 UTC+1, Parsifal wrote: >> >> Sorry i got confused. >> So there is no need to persist at all and just flush outside foreach when >> foreach is finished? I tought before every flush i need to use persist, so >> please clarify what is the purpose of persist if i don't need to use it in >> this case at all? >> > > Persist( ) is a bit confusing name for that method. Maybe it might better > have been called manage( ), but that name is not very clear too. But what > you do with persist( ) is making an entity managed, that is: all updates to > it will be taken into account at the next flush( ). When you retrieve > Entities via the Repository, using find( ), findBy( ) etc, they are > allready managed. So: no need to call persist( ) for them. > > -- > You received this message because you are subscribed to the Google Groups > "doctrine-user" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/doctrine-user. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "doctrine-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/doctrine-user. For more options, visit https://groups.google.com/d/optout.
