title: PHP MVC: Data Mapper pattern: class design
body: <p>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 ActiveRecord structure/pattern AT ALL.</p>
  
  <p>Let me give you an example:
  Normally, I could have an abstract class <code>AbstractDataMapper</code> inherited by all specific data mapper classes - like the <code>UserDataMapper</code> class. And then I could define a <code>findById()</code> method in <code>AbstractDataMapper</code>, to fetch a record of a specific table - like <code>users</code> - by a given <code>id</code> value, e.g. user id. But this would imply that I'd always fetch a record from a single table, without the possibility to use any left joins to also fetch some other details from some other tables corresponding to the given <code>id</code> - user id.</p>
  
  <p>So, my question is:
  Under these conditions - to which I myself obliged to, should I implement an abstract data mapper class, or each data mapper class should contain its own completely "proprietary" implementation of the data-access layer?</p>
  
  <p>I hope I could express my idea clear. Please tell me, if I was somehow unclear or you have any questions.</p>
  
  <p>Thank you very much for your time and patience.</p>