title: PHP MVC: Multiple databases, multiple data mappers?
body: <p>I am working on my HMVC project.</p>
  
  <p>Right now I am using data mappers in order to move data between the models (domain objects) and a MySQL database. Each mapper receives a MySQL adapter as dependency. The injected adapter receives a PDO instance (a database connection) as dependency and runs sql queries on the database.</p>
  
  <p>I also use a dependency injection container (Auryn).</p>
  
  <p>I'd like to be able to simultaneously retrieve data from storages of different types (MySQL database, PostgreSQL database, XML feeds, etc).</p>
  
  <p>Let's say, I want to retrieve <code>User</code> data from a <strong><code>PostgreSQL</code> database</strong> (by using <strong><code>PDO</code></strong> data-access abstraction), to change it, and to save it into a <strong><code>MySQL</code> database</strong> (by using <strong><code>mysqli</code></strong> data-access abstraction) on another server. So, there will be different data-access calls for the both database types.</p>
  
  <p>My question is:</p>
  
  <p>Should I create a different mapper for each storage type, like </p>
  
  <pre><code>UserMapperPgsql(PgsqlAdapter $adapter) 
  UserMapperMySql(MySqlAdapter $adapter)
  </code></pre>
  
  <p>, or should I create only one mapper with more adapters (one for each data type) as dependencies, like bellow?</p>
  
  <pre><code>UserMapper(PgsqlAdapter $adapter1, MySqlAdapter $adapter2, ...)
  </code></pre>
  
  <p>Thank you all for your suggestions!</p>