Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
CodeIgniter base CRUD model to remove repetition and increase productivity
branch: master

This branch is 178 commits behind jamierumbelow:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
LICENSE
README.md

README.md

codeigniter-base-model

Introduction

My CodeIgniter Base Model is an extended CI_Model class to use in your CodeIgniter applications. It provides a full CRUD base to make developing database interactions easier and quicker. It also includes a bunch of other cool stuff, including before and after create callbacks, validation and a some table name guessing.

Usage

Drag the MY_Model.php file into your application/core folder. CodeIgniter will load and initialise this class automatically for you. Extend all your model classes from MY_Model and all the functionality will be baked into your models automatically.

Naming Conventions

This class will try to guess the name of the table to use, by guessing the plural of the class name. If the table name isn't the plural and you need to set it to something else, just declare the $_table instance variable and set it to the table name. Some of the CRUD functions also assume that your primary key ID column is called 'id'. You can overwrite this functionality by setting the $primary_key instance variable.

Validation

This class also includes some excellent validation support. This uses the built-in Form Validation library and provides a wrapper around it to make validation automatic on insert. To enable, set the $validate instance variable to the rules array that you would pass into $this->form_validation->set_rules(). To find out more about the rules array, please view the library's documentation.

Upcoming Features

  • Before and after update callbacks
  • Better table name guessing
  • Better support for associations and JOINs

Special Thanks

Thanks to Phil Sturgeon and Dan Horrigan who have both contributed a great amount of code and ideas to this MY_Model.

Something went wrong with that request. Please try again.