Question

One thing I discovered in Kohana 3.x concerned the ORM and the MVC. In fact, far away in the ORM section I can read basic examples in controller. Where calls on databases are made, modified and saved directly to the database...This does not value the MVC concept.

class Controller_User extends Controller {
    function action_register() {
    $user = ORM::factory('User')
    ->values($this->input->post())
    ->save();
    }
}

They could have done this in their documentation

class Model_user extends ORM {
function register($array) {
return ORM::factory('User')->values($array)->save();
}
}

And simply call the Model::register($array) from the Controller.

I think to best practice resides in the useful of MVC. Any suggestion ?

Was it helpful?

Solution

The Kohana documentation often shows the quickest way to get results not necessarily the best way.

Best practice is really something you have to figure out for yourself by reading forums and blogs. One persons idea of best practice may not be another's.

Personally I agree with you and have thin controllers and do all the heavy lifting in the model but I'm sure many people would tell me I'm doing it all wrong ;-)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top