I have a around 30 entities and all querying the database.
Now i want that i should only get those records where i have ACTIVE = 1. My all tables have that field.
One way is to change all the queries i am using.
Is there any other alternative where i can just grab the query before executing and add the where clause from single function like any Listener or event
Indeed. It’s called a “filter” — you can activate and deactivate them as needed. See the manual here: http://docs.doctrine-project.org/en/latest/reference/filters.html.
You can configure them in Symfony2 using a “filters” node under the doctrine node in your config file. Each filter should have two subnodes: “class” and “enabled” (enabled should, of course; be true, and class should be an FQCN pointing towards the filter).