Welcome Guest, Not a member yet? Register   Sign In
Code separation with CI + Datamapper
#2

[eluser]WanWizard[/eluser]
The model remains the model as per the MVC definition.

Datamapper only provides the relationship logic, plus the generic methods to access your data. The idea is that you add the specific methods you need in your model to interact with your data to the model. Like you would do with a traditional CI model.
So yes, it's absolutely the idea that the model will house methods like 'get_book'. Do NOT start writing all your code in the controller and use Datamapper like you would use CI's AR!

For a Book model, you'll find methods like get_author(), a Author model get_all_books(), etc. Your controller only uses $author->get_all_books(). Again, like you would do normally.

There is generally no need to instantiate a model within a model. If a model has to interact with others, it is because there is a relationship between the two. Which Datamapper knows about, so you can access them via the current object ($this).


Messages In This Thread
Code separation with CI + Datamapper - by El Forum - 03-18-2011, 03:59 PM
Code separation with CI + Datamapper - by El Forum - 03-18-2011, 04:29 PM
Code separation with CI + Datamapper - by El Forum - 03-22-2011, 02:43 AM
Code separation with CI + Datamapper - by El Forum - 03-22-2011, 02:56 AM
Code separation with CI + Datamapper - by El Forum - 03-22-2011, 03:06 AM
Code separation with CI + Datamapper - by El Forum - 03-22-2011, 05:51 AM



Theme © iAndrew 2016 - Forum software by © MyBB