samedi 1 juillet 2017

PHP MVC Query builder class for building complex sql statements

This question is an extension of my post PHP MVC Data mapper pattern: class design. Actually, the answer to this question could be seen as a consequence of it.

I have a web MVC application with domain objects and data mappers. The class methods of the data mappers contain all database querying logic. I'm trying to avoid mirroring any database structure and, therefore, to achieve the maximum flexibility in constructing the sql statements. So, in principle, I'm trying to not make use of any ORM or Active Record structure/pattern AT ALL.

Now, let's suppose two things:

  • A data mapper abstract class - from which each specific data mapper class would inherit - does NOT exist. E.g: each data mapper class contains its own completely "proprietary" implementation of the data-access layer and, therefore, each data mapper class method can juggle with complex sql queries without any limitations.
  • The project is a complex one, with (very) complex queries on multiple databases and tables.

My question is: Under these circumstances, is the use of a query builder class - responsible for building the sql statements - a limitation or an advantage? I appreciate any arguments, or examples, or ideas.

Because the answer to this question is very important to me, I'll also put bounties on it in two days.

Thank you very much.

Aucun commentaire:

Enregistrer un commentaire