Remove calls to dropped orders table

This commit is contained in:
Romain Neutron
2013-10-07 18:36:52 +02:00
parent b7773a44ef
commit 097e1f21ae
2 changed files with 17 additions and 5 deletions

View File

@@ -12,6 +12,18 @@ use Doctrine\ORM\EntityRepository;
*/
class OrderRepository extends EntityRepository
{
/**
* Returns the orders initiated by a given user.
*
* @param \User_Adapter $user
*
* @return array
*/
public function findByUser(\User_Adapter $user)
{
return $this->findBy(array('usrId' => $user->get_id()));
}
/**
* Returns an array of all the orders, starting at $offsetStart, limited to $perPage
*

View File

@@ -768,6 +768,11 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
$this->app['EM']->remove($export);
}
$repo = $this->app['EM']->getRepository('Entities\Order');
foreach ($repo->findByUser($this) as $order) {
$this->app['EM']->remove($order);
}
$this->app['EM']->flush();
$sql = 'UPDATE usr SET usr_login = :usr_login , usr_mail = null
@@ -796,11 +801,6 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
$stmt->execute(array(':usr_id' => $this->get_id()));
$stmt->closeCursor();
$sql = 'DELETE FROM `order` WHERE usr_id = :usr_id';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute(array(':usr_id' => $this->get_id()));
$stmt->closeCursor();
$sql = 'DELETE FROM sselnew WHERE usr_id = :usr_id';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute(array(':usr_id' => $this->get_id()));