Skip to content
World Wide Web Server edited this page Jul 4, 2012 · 45 revisions

This page details an implementation of Active Record for CodeIgniter that more accurately mimics the way Ruby on Rails works with models. It allows you to abstract large amounts of the searching and creation code out of your models, and can help with streamlining your controller code as well.

File:Activerecord.php.zip

[b]NOTE! Due to some of the code this technique uses, it will only work if you are running PHP5![/b]

[h3]Implementation[/h3]

To begin using the ActiveRecord class, download the most recent version and save it into your [b]/application/libraries[/b] folder. This file replaces the CodeIgniter Model class, and all your models will inherit from it.

Next, edit [b]/application/config/autoload.php[/b] and make sure that both the ActiveRecord and database libraries are automatically loaded when CodeIgniter runs:

[code] $autoload['libraries'] = array('activerecord', 'database'); [/code]

PAGE UNDER CONSTRUCTION

Clone this wiki locally