Say I have the following classes:
class Store
{
/**
* @ManyToMany(targetEntity="PaymentMethod")
*/
protected $paymentMethods;
}
class PaymentMethod
{
}
When we delete (or just disable, without actually removing from the database) a PaymentMethod
, we'd like that this paymentMethod
gets removed from all the Store::$paymentMethods
collections.
Up to now, we've been using raw SQL queries on the junction table for this:
DELETE FROM StorePaymentMethod WHERE paymentMethodId = ?
Is there a way to do that in Doctrine, preferably in DQL?
$stores
collection inPaymentMethod
to an empty collection and persist it? You would need to invalidate allStore
objects in memory to ensure that their reciprocal links did not keep the records. Though in an ideal world, the accessors methods you write to perform the empty would go through theStores
removing the reciprocal links. – Studied