Archive

Posts Tagged ‘symfony admin generator 1.4’

Symfony Batch Delete while using Doctrine Soft Delete

March 5th, 2010 2 comments

Doctrine Soft Delete is a fabulous method that will set a deleted_at column when the user deletes a record. So it doesn’t really delete the record but timestamps it as deleted.

This offers wonderful functionality to you admin generated app. But there’s a catch!

If you’re using a batch delete you’ll notice that the code uses DQL (Doctrine Query Language) to make the delete and not actually calling the delete() method from the class.

I fixed this quickly by actually time stamping deleted_at field:

$count = Doctrine_Query::create()
      ->update('myclass')
      ->set('deleted_at','now()')
      ->whereIn('id', $ids)
      ->execute();

Symfony should account for this so that soft delete will work properly with admin generated code.