DMZ DataMapper Best Practices - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: DMZ DataMapper Best Practices (/showthread.php?tid=32660) |
DMZ DataMapper Best Practices - El Forum - 07-30-2010 [eluser]titoneo[/eluser] Hello I'm looking for best practices for DMZ DataMapper. I think it's pretty good. If I have a model called 'Project' which has many lines of project ('lineproject'), is associated with a 'Client' and a 'Rule' In other words, Code: class Project extends DataMapper Ok, now if I want only the 'lines' or only the 'client' or only the 'rule' , where will you include the method to obtain it? Some methods in the Project model, or a method in their respective models? Another question, if I want to get all lines of a project, I have to instantiate a 'Line' or 'Project' model to call the method, it would be better to make static methods? Thanks DMZ DataMapper Best Practices - El Forum - 07-30-2010 [eluser]WanWizard[/eluser] Code: // to get project 1 No need to create methods anywhere, all built-in. Go through the manual again, DMZ has tons of options and, because of all the relations, multiple ways to skin a cat... DMZ DataMapper Best Practices - El Forum - 07-30-2010 [eluser]titoneo[/eluser] Yes there are a lot of options to do the same thing, but I want implement an abstraction layer to encapsulate 'actions' (DAO pattern) and my question is where place this methods, what is the best practices to place its? I think that if you want a 'lines' of a project, the method should reside in 'lines' model. But when you need information of some models together, were is the correct place? Thanks DMZ DataMapper Best Practices - El Forum - 12-14-2010 [eluser]Alface[/eluser] [quote author="titoneo" date="1280513270"]Yes there are a lot of options to do the same thing, but I want implement an abstraction layer to encapsulate 'actions' (DAO pattern) and my question is where place this methods, what is the best practices to place its? I think that if you want a 'lines' of a project, the method should reside in 'lines' model. But when you need information of some models together, were is the correct place? Thanks[/quote] I have the same problem. My controllers become very large =/ Anyone can help us? DMZ DataMapper Best Practices - El Forum - 12-14-2010 [eluser]WanWizard[/eluser] This type of code shouldn't be in your controllers to begin with, it belongs in a model. If you want to abstract even more, on top of Datamapper, you can just add the additional methods to the model: Code: class Users extend Datamapper Code: // get all admins If you have very complex methods that span multiple tables, I suggest creating a normal CI model, and use that for your abstract methods. In those methods, you load and use your Datamapper models. |