It will work when you correctly code it, but you don't need Doctrine for
that... You are just directly managing tables. BTW: no 2 flushes needed.
With an ORM you could also have a collection of banned email addresses and
you add or remove addresses from that. But then you'll have to start
thinking in objects/entities instead of in tables. And from what object
would a collection of banned email addresses then be a part. But I'll leave
it here. As said: no time anymore. Good luck with your tables.
On Saturday, 19 April 2014 11:34:10 UTC+2, Parsifal wrote:
>
> I think this table should become empty before adding new data? so I do
> this:
> $emails = $em->getRepository('Entities\BannedEmail')->findAll();
> foreach ($emails as $email) {
> $deletBanned = $em->remove($email);
> }
> $em->flush();
>
> if (!empty($_POST['bannedEmails'])) {
> $emails = @explode("\n", $_POST['bannedEmails']);
> foreach ($emails as $email) {
> $banned = new Entities\BannedEmail($email);
> $em->persist($banned);
> }
> }
> $em->flush();
>
> And also noticed I should flush after removing and after adding to prevent
> duplicate entry exception. any suggestion to improve this?
>
>
>
>
>
>
>
> On Sat, Apr 19, 2014 at 1:56 PM, Herman Peeren
> <[email protected]<javascript:>
> > wrote:
>
>> On Saturday, 19 April 2014 11:09:20 UTC+2, Parsifal wrote:
>>>
>>> am I correct that I should instantiate the entity and persist it inside
>>> loop and flush it when loop finished?
>>>
>>
>> Yes.
>>
>> But: look out with what is allready in database.
>> And: maybe you should rethink this model, for it probably could be
>> improved.
>>
>> --
>> 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] <javascript:>.
>> To post to this group, send email to [email protected]<javascript:>
>> .
>> 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.