Feb 2009: An updated version of the code for CodeIgniter 1.7.x can be found here.
I developed this extension of CodeIgniter’s Model last year, but never had the chance to publish it. The main purpose of this extension is to make a dev’s life easy. This extension has been used by several of my devs at RBS and has been proved to increase productivity and reduce the number of painful small queries to write. Their enthusiasm has driven me to post this for the CI fans out there.
Without much babble, let’s get into point. I’ve explained the process of installing it and then showed some example uses. For starter, click here to download it. Now follow these steps to get started:
1. Replace the system/libraries/Model.php file with the attached Model.php (CodeIgniter version 1.6.3)
2. For each of your tables, you will need to create a model file in system/application/models.
3. Lets say we have a "products" table whose schema is as follows:
4. Now we need to create system/application/models/product.php:
5. From any controller, you can load the Model as instructed in the CI manual. Here are some sample usage of the model functions:
7. There are a number of other helpful functions in this file. If you have a careful look, you’ll discover that some of them are really handy.
UPDATE: I forgot to give due credit to the wonderful developers of CakePHP – I’ve taken inspiration from their Model implementation while building this one for CodeIgniter.
Extended Model for CodeIgniter
Downloaded: [downloadcounter(model-ci)] times
MORE UPDATE: Download the version for CodeIgniter 1.7.x here.