EllisLab text mark
Advanced Search
     
SMC - Simple Model for CodeIgniter (CRUD)
Posted: 06 September 2012 01:02 PM   [ Ignore ]
Avatar
Joined: 2011-10-12
103 posts

SMC (simple model for codeigniter) is a lightweight CRUD model for CodeIgniter.

Check out the Documentation on Bitbucket!

Advantages

- easy to install (2 files)
- easy to setup (just extend SMC_Model)
- easy to use (see below)
- short, readable syntax
- method chaining
- all based on CodeIgniters own active record class


Features

- OOP approach
- supports all active record methods
- often used methods implemented ( like find($column, $value) )
- magic constructor to inject values into a new instance
- wiki with a lot of documentation and examples


Current version: 1.2.1


Download and Documentation


Submit Bugs and Issues


Examples

// INSERT data

$user           = new User();

$user->name     'new user';
$user->email    'user@mail.de';
$user->password '123456';

$user->create();

// UPDATE data

$user User::find('name''new user');

$user->password 'new password';

$user->save();

// REMOVE data

$user User::find('id'1);

$user->remove();

// SELECT data

$users User::query()->where('name''a user')->or_where('name''another user')->get();

// ITERATE RESULTS

foreach ($users as $user{
        $user
->name 'a new name';
        
$user->save();
 Signature 

SMC - full CRUD Model for CodeIgniter:
forum: http://codeigniter.com/forums/viewthread/223845/

 
Posted: 10 September 2012 01:46 PM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Joined: 2012-08-18
4 posts

I like the concept…seems very useful : )

 
Posted: 10 September 2012 04:33 PM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Avatar
Joined: 2011-10-12
103 posts
Th3Location - 10 September 2012 01:46 PM

I like the concept…seems very useful : )

First of all, thank you for the feedback. I hope you checked also my bitbucket wiki page for a full guide about this.

If you have any question regarding the use, or if you need some best practise examples dont hesitate to ask me.

The examples above are valid for version 1.0 of SMC.

 Signature 

SMC - full CRUD Model for CodeIgniter:
forum: http://codeigniter.com/forums/viewthread/223845/

 
Posted: 09 October 2012 04:38 PM   [ Ignore ]   [ # 3 ]   [ Rating: 0 ]
Avatar
Joined: 2011-10-12
103 posts

I updated SMC to version 1.1 and added some new features like:

- auto guess table name
- auto guess primary key
- __toString method
-  model iteration
- ability for static method chaining
- save_new() method

 Signature 

SMC - full CRUD Model for CodeIgniter:
forum: http://codeigniter.com/forums/viewthread/223845/

 
Posted: 09 October 2012 05:02 PM   [ Ignore ]   [ # 4 ]   [ Rating: 0 ]
Joined: 2011-02-23
882 posts

Just had a quick glance at your code… And added two issues raspberry But they aren’t any real issues but suggestions, which may enhance code readability, speed, and allowing others to easily use the model within their application(s) wink

 Signature 

ignited Community Framework (WiP)  |  Read the User’s Guide. It won’t bite.

STOP! Before posting your questions, remember the WWW Golden rule:
What did you try? What did you get? What did you expect to get?

CI example .htaccess

 
Posted: 10 October 2012 03:44 AM   [ Ignore ]   [ # 5 ]   [ Rating: 0 ]
Avatar
Joined: 2011-08-28
136 posts

Very interesting. Make me remember of those django model.
This can be the “real ORM” I was searching for smile

 Signature 

Homepage : http://www.getnocms.com
Github page : https://github.com/goFrendiAsgard/No-CMS

A free CodeIgniter based CMS-Framework, It is not just another CMS !!!

 
Posted: 10 October 2012 06:16 AM   [ Ignore ]   [ # 6 ]   [ Rating: 0 ]
Avatar
Joined: 2011-10-12
103 posts
PhilTem - 09 October 2012 05:02 PM

Just had a quick glance at your code… And added two issues raspberry But they aren’t any real issues but suggestions, which may enhance code readability, speed, and allowing others to easily use the model within their application(s) wink

Thank you for your contributing. I added all your improvements and tagged a new version.

issue #1: advanced table guessing

Ability to guess the tablename even if you suffix your model with ‘_m’ or ‘_model’ (case insensitive)

issue #2: speed up __construct() method

 Signature 

SMC - full CRUD Model for CodeIgniter:
forum: http://codeigniter.com/forums/viewthread/223845/

 
Posted: 14 October 2012 06:36 PM   [ Ignore ]   [ # 7 ]   [ Rating: 0 ]
Avatar
Joined: 2011-10-12
103 posts

I massivly enhanced the SMC wiki. Have fun using it.

 Signature 

SMC - full CRUD Model for CodeIgniter:
forum: http://codeigniter.com/forums/viewthread/223845/

 
Posted: 26 October 2012 05:10 AM   [ Ignore ]   [ # 8 ]   [ Rating: 0 ]
Avatar
Joined: 2012-10-23
58 posts

This is very very cool dude! I’ll check it and maybe I can append some other functions I usually need, but after a quick view looks awesome!

Thanks!

 
Posted: 31 October 2012 08:15 AM   [ Ignore ]   [ # 9 ]   [ Rating: 0 ]
Avatar
Joined: 2011-10-12
103 posts
jojo777 - 26 October 2012 05:10 AM

This is very very cool dude! I’ll check it and maybe I can append some other functions I usually need, but after a quick view looks awesome!

Thanks!

Would be very kind if you all post your experience with SMC.

I need some feedback to improve usability.

 Signature 

SMC - full CRUD Model for CodeIgniter:
forum: http://codeigniter.com/forums/viewthread/223845/

 
Posted: 31 January 2013 02:23 PM   [ Ignore ]   [ # 10 ]   [ Rating: 0 ]
Avatar
Joined: 2013-01-31
5 posts

I just found your code. Will try it out. Looks great, working with the CI activeRecord is really hell when you’re used to better stuff smile

It seems I’m going to use Doctrine or something like that instead. As far as I see Your thing does not support table relations. Correct me if wrong, I might consider it for one of my next projects.

 
Posted: 25 February 2013 05:04 AM   [ Ignore ]   [ # 11 ]   [ Rating: 0 ]
Joined: 2010-12-04
2 posts

Great! At a quickly glance, this seem to be the right orm i’m searching all the way. I’ll try it in my project.

 
Posted: 26 February 2013 08:12 PM   [ Ignore ]   [ # 12 ]   [ Rating: 0 ]
Joined: 2011-01-08
46 posts

how this orm handles relationship (one to one,one to many etc)? any guide?

 
Posted: 24 April 2013 08:58 AM   [ Ignore ]   [ # 13 ]   [ Rating: 0 ]
Avatar
Joined: 2011-10-12
103 posts
Mantero - 26 February 2013 08:12 PM

how this orm handles relationship (one to one,one to many etc)? any guide?

Currently it supports no relations. Feel free to fork and add them.

 Signature 

SMC - full CRUD Model for CodeIgniter:
forum: http://codeigniter.com/forums/viewthread/223845/