In the Product entities the links to this DownloadGroup are deleted to keep
it consistent (in database: a foreign key constraint). That is not the same
as cascaded delete, where the products belonging to a DownloadGroup are
deleted. But the link to the deleted group must be deleted from the
products.
Somewhere in getting the Product entities you used a 'productId', but did
not define it. Maybe in the definition of the OneToMany to Product? You
said DownloadGroup "is ManyToOne to Product entity". Have you got the right
OneToMany and ManyToOne? For I think *a downloadgroup can contain many
products, but a product can only be in 1 downloadgroup?* In that case the
Product is the owner, has a $downloadGroup field with ManyToOne to a
DownloadGroup entitity and a DownloadGroup has a $products field with a
OneToMany to the Product entity. From what you tell here it looks a bit the
other way around, with a DownloadGroup having only one Product, thereby
DownloadGroup being the owner and linking to a Product with a productId-key
that does not exist...
On Wednesday, 5 March 2014 23:50:36 UTC+1, Parsifal wrote:
>
>
> I have a Download Group with just two rows: id, groupName
> This is ManyToOne to Product entity. When I want to delete a Download
> Group standalone, I use this:
>
> $object = $em->find('Entities\DownloadGroup', $_GET['id']);
>
> if ($object !== null) {
>
> $group_name = $object->getGroupName();
>
> $em->remove($object);
>
> $em->flush();
>
>
> $error = false;
>
> $message = "Download group ($group_name) has been
> deleted.";
>
> } else {
>
>
> $error = true;
>
> $message = "Invalid download group.";
>
> }
> I use getGroupName() before deleting to get the download group name to
> prepare the message for EventLog.
> But on deleting I get E_NOTICE:
> Undefined index: productId in
> /vendor/doctrine/common/lib/Doctrine/Common/Proxy/AbstractProxyFactory.php
> on line 121
> productId property belongs to Product entity not to DownloadGroup. I am
> not using cascade deletion too. the deleted download group may not have an
> assigned product too.
> If I remove getGroupName() from code above, I won't get the notice any
> more. But I need it for EventLog, so how can I fix that notice message that
> is related to Product entity? please advice.Look forward to hear from you.
>
>
>
>
--
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/groups/opt_out.