![]() |
CodeIgniter Data Mapper / Domain Objects - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Feature Requests (https://forum.codeigniter.com/forumdisplay.php?fid=29) +--- Thread: CodeIgniter Data Mapper / Domain Objects (/showthread.php?tid=67522) |
CodeIgniter Data Mapper / Domain Objects - EpicKris - 03-04-2017 It would be useful to have a data mapper for domain objects. Database Example: Code: CREATE TABLE user Currently with CodeIgniter 4 you can create objects such as: PHP Code: class User However passing the object to a model won't work with `createdDateTime` and `updatedDateTime` fields. I create objects such as: PHP Code: class User Again, passing the object to a model won't work with `userId`, `firstName`, `lastName`, `createdDateTime` and `updatedDateTime` fields. And your domain objects may look different to your table fields and may even include other relational domain objects. It would be useful to map the data to and from domain objects using a mapper. What are peoples thoughts on this? RE: CodeIgniter Data Mapper / Domain Objects - kilishan - 03-05-2017 You're absolutely correct. The solution I put in place currently was a quick hack late one night to try and improve the compatibility of using objects for saving. I obviously didn't think it all of the way through. ![]() I'm definitely open to the idea. I know the idea of a DataMapper has been bandied about in our private group, also, so I don't believe we'd get too much argument from there. And having custom classes workable with the model is a must, I personally believe. I believe you've opened an issue at GitHub, so we can discuss implementation details there. |