views:

34

answers:

1

In an application that is using Zend Framework 1.10 and Doctrine 1.2, where should the DQL statements live if our application is built such that it has a Service Layer and a Gateway(aka Doctrine_Table) layer.

It seems that our possibilities include:

1) Placing the DQL statements in the Service layer which seems to be a bit too high in our application hierarchy to store DQL.

2) Placing the DQL statements within each model's Table/Gateway which seems a bit redundant because we also need to expose the DQL statements that do things such as getAllUsers() through the Service layer.

Which of these is a preferable design? We intend to make use of the Service layer as much as possible so that other projects might consume various parts of our application.

+1  A: 

I our projects we put most of the queries in the service layer, except when the service is not required at all.

There is also third option, you haven't mentioned, i.e. putting the base queries in table, and then making them concrete in the service:

// in the service
$q = $table->getSomeQuery();
$q->addWhere(...)
  ->findBySome('name')
  ->execute();
...
takeshin