I am working on my HMVC project.
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.
I also use a dependency injection container (Auryn).
I'd like to be able to simultaneously retrieve data from storages of different types (MySQL database, PostgreSQL database, XML feeds, etc).
Let's say, I want to retrieve User
data from a PostgreSQL
database (by using PDO
data-access abstraction), to change it, and to save it into a MySQL
database (by using mysqli
data-access abstraction) on another server.
My question is:
Should I create a different mapper for each storage type (like
UserMapperPgsql(PgsqlAdapter $adapter)
UserMapperMySql(MySqlAdapter $adapter)
), or should I create only one mapper with more adapters (one for each data type) as dependencies (like
UserMapper(PgsqlAdapter $adapter1, MySqlAdapter $adapter2, ...)
)?
Thank you all for your suggestions!
Aucun commentaire:
Enregistrer un commentaire