I am working with MySql and results/rows are returned within an array.
I do understand that in the end, the model layer "goal" is to return an object once the SGBD query is processed.
So, should the process of converting rows (or a single row) into an object be integrated in the DataMapper (which is part of the Model layer) or should it be the responsibility of a third service that would be injected in the DataMapper?
Thank you
So, should the process of converting rows (or a single row) into an object be integrated in the DataMapper.
Well yes it's the responsibility of the data mapper. It should return an entity, not a result set.
or should it be the responsibility of a third service that would be injected in the DataMapper?
This is also a possibility, google to "UnitOfWork" I think that's what you are looking for. https://www.sitepoint.com/implementing-a-unit-of-work/
You can also take a look at the doctrine source https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/EntityManager.php
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With