Fork me on GitHub

CRUD in Codeigniter

14 Jan 2008 – Denver

So a while back I started using MVC PHP framework called Code Igniter. The framework is really pretty basic, and unlike cake or rails, it doesn’t automatically do much for you in the models. So to make CRUD stuff easier, I created a basic parent model that does all the work. You can get it from gist.

To use it all you have to do is put the file in your libraries folder and then do something like this in your model:


<?php class Something_model extends MY_Model { function __construct() { parent::MY_Model(); $this->default_table = 'some_table'; } }

And then you’ll have access to things like “$this→Something_model→get_all()” all for free right in your controller. :)




blog comments powered by Disqus

Related Posts