views:

26

answers:

2

http://www.doctrine-project.org/documentation/manual/1_0/ru/behaviors:core-behaviors:softdelete

You are required to enable DQL callbacks in order for all executed queries to have the dql callbacks executed on them. In the SoftDelete behavior they are used to filter the select statements to exclude all records where the deleted_at flag is set with an additional WHERE condition.

I have set a model behaviour to SoftDelete, and when I $Model->delete() it, the actual db entry gets altered as expected.

Unfortunately, Doctrine::getTable('Model')->findAll() still includes the record, where deleted_at is set.

Looking through the documentation, I feel, it has to do with DQL Callbacks not being enabled in symfony. Googling didn't help.

How and where do I enable DQL callbacks in Symfony?

Thanks

A: 

Ok, I found it in old documentation for version 1.2 http://www.symfony-project.org/doctrine/1_2/en/03-Configuration

config/ProjectConfiguration.class.php

 public function configureDoctrine(Doctrine_Manager $manager)
  {
    $manager->setAttribute(Doctrine_Core::ATTR_USE_DQL_CALLBACKS, true);
  }

Don't forget to $ ./symfony cc clear your cache.

tilman
It's also mentioned in 1.4 docs: http://www.symfony-project.org/more-with-symfony/1_4/en/08-Advanced-Doctrine-Usage#chapter_08_sub_the_event_listener
kuba
Unfortunately didn't find it through google. Thanks for your comment, though, will try and memorize the symfony documentation better. Not the contents, but at least so I know where to look next time ;)
tilman
Yept, google usually finds old docs. Using 'symfony 1.4' instead of 'symfony' in the query string usually helps.
kuba
+1  A: 

Hi,

You can also do it in the databases.yml file

all:
  doctrine:
    class: sfDoctrineDatabase
    param:
      dsn:      mysql:host=localhost;dbname=database
      username: user
      password: password
      attributes:
        use_dql_callbacks: true
jwconsulting