0

I need to modify all queries that are executed through Zend\Db before sending them to DB.

Basically it needs to add additional WHERE statement to all selects, updates and deletes and additional column and value in inserts.

I was thinking about writing my own TableGateway feature for that, the problem is that I would like to avoid being restricted to TableGateway alone and have this functionality while using Zend\Db\Adapter and TableGateway at the same time.

Adam
  • 873
  • 7
  • 33

2 Answers2

1

You can have a look at some of the events dispatched from the table gateway if that make sense in your context: http://framework.zend.com/apidoc/2.4/namespaces/Zend.Db.TableGateway.Feature.EventFeature.html

There is a preSelect event that is triggered and which you can probably listen to.

Thomas Dutrion
  • 1,844
  • 1
  • 11
  • 9
  • thanks Thomas, the problem is that all `Features` are for `TableGateway` only, I need to have such flexibility of altering queries on an adapter level. – Adam Feb 26 '16 at 18:19
1

I have ended up writing custom db adapter that handles all the logic. I'll probably share it as an open source if I'll have a time to clean up the code.

Adam
  • 873
  • 7
  • 33