• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
MY_Model Base CRUD Model

#1
[eluser]Jamie Rumbelow[/eluser]
I've recently released an extended Model class to use in CodeIgniter applications that provides a base CRUD pattern for your models. It gives you the core CRUD functionality, as well as support for before_create and after_create callbacks and some clever table name guessing.

Usage
Drag the MY_Model.php file into your application/libraries folder. CodeIgniter will load and initialise this class automatically for you. Then all you have to do is make sure all your models extend from MY_Model and all the functionality will be baked into your models automatically!

Tutorial
I've written a tutorial that takes a reasonable look at the functionality provided by the entire class, as well as my MY_Controller Controller System on my delightful blog. Check it out and feel free to leave a comment.

Download
You can get the source directly from GitHub, where I'll be updating the library. You can also fork it and customise it yourself! Alternatively, you can download it as a .zip or a .tar.

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.

Upcoming Features
* Support for validations
* Function reference
* Before and after update callbacks
* Better table name guessing
* Better support for associations and JOINs

Version History
* 1.1.0 Two new methods, count_by() and count_all(), made use of some ActiveRecord methods and optimisations
* 1.0.5 Added support for custom primary keys
* 1.0.0 First release


Messages In This Thread
MY_Model Base CRUD Model - by El Forum - 11-08-2009, 07:02 AM
MY_Model Base CRUD Model - by El Forum - 11-08-2009, 07:43 AM
MY_Model Base CRUD Model - by El Forum - 11-08-2009, 10:58 AM
MY_Model Base CRUD Model - by El Forum - 11-08-2009, 11:01 AM
MY_Model Base CRUD Model - by El Forum - 11-08-2009, 05:06 PM
MY_Model Base CRUD Model - by El Forum - 11-09-2009, 09:05 AM
MY_Model Base CRUD Model - by El Forum - 11-09-2009, 12:15 PM
MY_Model Base CRUD Model - by El Forum - 11-09-2009, 12:28 PM
MY_Model Base CRUD Model - by El Forum - 12-02-2009, 03:09 AM
MY_Model Base CRUD Model - by El Forum - 12-02-2009, 03:22 AM
MY_Model Base CRUD Model - by El Forum - 12-17-2009, 05:02 PM
MY_Model Base CRUD Model - by El Forum - 12-18-2009, 07:19 AM
MY_Model Base CRUD Model - by El Forum - 12-18-2009, 07:48 AM
MY_Model Base CRUD Model - by El Forum - 01-04-2010, 01:28 PM
MY_Model Base CRUD Model - by El Forum - 01-04-2010, 04:36 PM
MY_Model Base CRUD Model - by El Forum - 01-04-2010, 08:37 PM
MY_Model Base CRUD Model - by El Forum - 01-17-2010, 02:16 AM
MY_Model Base CRUD Model - by El Forum - 01-17-2010, 02:57 AM
MY_Model Base CRUD Model - by El Forum - 01-17-2010, 03:19 AM
MY_Model Base CRUD Model - by El Forum - 01-17-2010, 03:27 AM
MY_Model Base CRUD Model - by El Forum - 01-17-2010, 12:37 PM
MY_Model Base CRUD Model - by El Forum - 01-17-2010, 12:43 PM
MY_Model Base CRUD Model - by El Forum - 01-17-2010, 12:46 PM
MY_Model Base CRUD Model - by El Forum - 01-17-2010, 12:48 PM
MY_Model Base CRUD Model - by El Forum - 01-17-2010, 12:52 PM
MY_Model Base CRUD Model - by El Forum - 01-17-2010, 12:59 PM
MY_Model Base CRUD Model - by El Forum - 01-17-2010, 01:12 PM
MY_Model Base CRUD Model - by El Forum - 01-17-2010, 03:31 PM
MY_Model Base CRUD Model - by El Forum - 01-17-2010, 04:15 PM
MY_Model Base CRUD Model - by El Forum - 01-17-2010, 04:26 PM
MY_Model Base CRUD Model - by El Forum - 01-17-2010, 08:20 PM
MY_Model Base CRUD Model - by El Forum - 01-23-2010, 06:36 PM
MY_Model Base CRUD Model - by El Forum - 03-06-2010, 09:20 AM
MY_Model Base CRUD Model - by El Forum - 03-09-2010, 05:43 AM
MY_Model Base CRUD Model - by El Forum - 03-09-2010, 05:46 AM
MY_Model Base CRUD Model - by El Forum - 03-09-2010, 05:59 AM
MY_Model Base CRUD Model - by El Forum - 03-09-2010, 08:30 AM
MY_Model Base CRUD Model - by El Forum - 03-09-2010, 08:46 AM
MY_Model Base CRUD Model - by El Forum - 03-23-2010, 08:17 AM
MY_Model Base CRUD Model - by El Forum - 04-04-2010, 05:11 AM
MY_Model Base CRUD Model - by El Forum - 04-04-2010, 05:24 AM
MY_Model Base CRUD Model - by El Forum - 04-04-2010, 06:03 AM
MY_Model Base CRUD Model - by El Forum - 04-04-2010, 06:10 AM
MY_Model Base CRUD Model - by El Forum - 04-04-2010, 06:21 AM
MY_Model Base CRUD Model - by El Forum - 04-04-2010, 06:28 AM
MY_Model Base CRUD Model - by El Forum - 04-04-2010, 12:06 PM
MY_Model Base CRUD Model - by El Forum - 04-04-2010, 12:14 PM
MY_Model Base CRUD Model - by El Forum - 05-10-2010, 09:22 AM
MY_Model Base CRUD Model - by El Forum - 05-10-2010, 12:47 PM
MY_Model Base CRUD Model - by El Forum - 05-11-2010, 10:40 AM
MY_Model Base CRUD Model - by El Forum - 05-11-2010, 10:55 AM
MY_Model Base CRUD Model - by El Forum - 05-27-2010, 07:04 PM
MY_Model Base CRUD Model - by El Forum - 05-28-2010, 02:12 AM
MY_Model Base CRUD Model - by El Forum - 06-03-2010, 01:15 AM
MY_Model Base CRUD Model - by El Forum - 06-03-2010, 02:36 AM
MY_Model Base CRUD Model - by El Forum - 06-03-2010, 01:29 PM
MY_Model Base CRUD Model - by El Forum - 08-02-2010, 04:25 AM
MY_Model Base CRUD Model - by El Forum - 08-10-2010, 09:52 PM
MY_Model Base CRUD Model - by El Forum - 05-03-2012, 03:58 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.