Skip to content

Instantly share code, notes, and snippets.

@jbouzekri
jbouzekri / FeatureContext.php
Created February 27, 2015 18:48
A nice wait for js calls ending function in behat
<?php
/**
* @author Gildas Quéméner <gildas@akeneo.com>
* @copyright 2013 Akeneo SAS (http://www.akeneo.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
use Behat\Behat\Exception\BehaviorException;
use Behat\Mink\Driver\Selenium2Driver;

What's the difference between cascade="remove" and orphanRemoval=true in Doctrine 2

TLDR: The cascade={"remove"} is like a "software" onDelete="CASCADE", and will remove objects from the database only when an explicit call to $em->remove() occurs. Thus, it could result in more than one object being deleted. orphanRemoval can remove objects from the database even if there was no explicit call to ->remove().

I answered this question a few times to different people so I will try to sum things up in this Gist.

Let's take two entities A and B as an example. I will use a OneToOne relationship in this example but it works exactly the same with OneToMany relationships.

class A