News Feed
Jobs Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

AskAboutPHP.com:
CodeIgniter Extending the native 'Model' and make it your own.
November 12, 2008 @ 09:31:24

The AskAboutPHP.com blog has posted a helpful new tutorial for those using CodeIgniter out there - how to extend the native Model class to bend it to your will.

I'm in the process of creating models for my CI project, and realized that certain functions within the models were getting repetitive. Using CI's ability to create my own custom libraries, I was able to create my own custom 'Model' which extends from the core 'Model' object. How this simple architecture has cleaned up my code is simply remarkable.

Rather than overwriting the main Model.php file with some of your own changes, he suggests creating a new library, a "parent model" that can be extended instead to provide some common functions that all of your application's models might need. For something a bit more complex, he also points to this library that extends the models to give it CakePHP-like functionality.

0 comments voice your opinion now!
codeigniter framework model extend custom parent library


blog comments powered by Disqus

Similar Posts

Andrew Podner: CodeIgniter: Keeping M-V-C straight

Chris Hartjes' Blog: 10 Days Later - Early Impressions of CakePHP vs. CodeIgniter

TheWorkAround.com: Determining, what makes a good framework?

Matthew Weir O'Phinney's Blog: Introducing Phly_Struct and Phly_Config

Jani Hartikainen's Blog: Understanding Doctrine's NestedSet feature


Community Events











Don't see your event here?
Let us know!


language application unittest symfony2 facebook framework security package database hhvm performance project podcast introduction hack install component composer release example

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework