CodeIgniter + Doctrine: CRUD in the controller?

I am new to MVC, CodeIgniter, and Doctrine, so maybe my question is not that important. Forgive me if this is so.

I read CodeIgniter + Doctrine tutorials at PHPandStuff.com . I really like what I saw in the Doctrine, and I want to use it for my project. However, since all database-related operations must be stored in the model, and not in the controller, should the CRUD operations that use Doctrine also be resultant in the Doctrine model? If so, how?

Thank you in advance

+4
source share
1 answer

If you do not want to write DQL to the controller (this is good), you can put separate functions in your model that simply work with the functionality provided by the extended classes.

For example, if you have a class called User and you need to save it, you could just

 class User extends BaseUser //or whatever you want { public function saveNewUser($data) { //setting the userdata eg $this->username try { $this->save(); .... } catch (Doctrine_Connection_Mysql_Exception $e) { ... } } } 

So, you have all the functions inside the model, as you would like.

+4
source

All Articles