[eluser]pierlooqup[/eluser]
Hello,
i've been using CI for a year now and I decided to use DM for my newest project.
I've read the documentation and I quite got the hang of it all - the only thing i'm a little concerned with, is about code separtion. Basically i'm having a hard time figuring out what's the best practice to achieve a well structured architecture that makes sense.
The proposed examples in the docs cover a fairly basic scenario - the DM models define the validation rules and the type of relationship each model has. Very little is said about where to actually place the model access logic code, especially in less trivial scenarios.
Say you are building a typical CRUD interface for a book catalogue:
a Book hasOne Author
an Author hasMany Books
and you want to add books, edit them etc.
My concern with putting everything in a Controller is that the Model is then ultra thin, while the controller will grow indefinitely. Also, (afaik) a Model is where you're supposed to not only declare a Model's "data structure" (and validation rules), but also its "access" logic (i.e. methods to get / set the model's data etc...) And this is definitely NOT trivial when a Model relies on other Models to work...
In the example above, would it make sense to write a "get_book" method inside the Book Model if you wanted to also return a book's author? Is it a good idea to load a model and instantiate it inside another model? Am I doing it all wrong? Gosh!
I'm not sure if my question is clear... but I'd love to be pointed to some more in depth examples to get a better understanding of what's the best way to use the DM library in advanced (or less trivial) cases.