CodeIgniter Forums
SMC - Simple Model for CodeIgniter (CRUD) - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forum-22.html)
+--- Thread: SMC - Simple Model for CodeIgniter (CRUD) (/thread-54382.html)

Pages: 1 2


SMC - Simple Model for CodeIgniter (CRUD) - El Forum - 09-06-2012

[eluser]alexwenzel[/eluser]
SMC (simple model for codeigniter) is a lightweight CRUD model for CodeIgniter.

Check out the Documentation on Bitbucket!

Download and Documentation


Submit Bugs and Issues


Examples


Code:
// INSERT data

$user           = new User();

$user->name     = 'new user';
$user->email    = '[email protected]';
$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();
}



SMC - Simple Model for CodeIgniter (CRUD) - El Forum - 09-10-2012

[eluser]Unknown[/eluser]
I like the concept...seems very useful : )


SMC - Simple Model for CodeIgniter (CRUD) - El Forum - 09-10-2012

[eluser]alexwenzel[/eluser]
[quote author="Th3Location" date="1347299204"]I like the concept...seems very useful : )[/quote]

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.


SMC - Simple Model for CodeIgniter (CRUD) - El Forum - 10-09-2012

[eluser]alexwenzel[/eluser]
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



SMC - Simple Model for CodeIgniter (CRUD) - El Forum - 10-09-2012

[eluser]PhilTem[/eluser]
Just had a quick glance at your code... And added two issues Tongue 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


SMC - Simple Model for CodeIgniter (CRUD) - El Forum - 10-10-2012

[eluser]goFrendiAsgard[/eluser]
Very interesting. Make me remember of those django model.
This can be the "real ORM" I was searching for Smile


SMC - Simple Model for CodeIgniter (CRUD) - El Forum - 10-10-2012

[eluser]alexwenzel[/eluser]
[quote author="PhilTem" date="1349816545"]Just had a quick glance at your code... And added two issues Tongue 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[/quote]

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


SMC - Simple Model for CodeIgniter (CRUD) - El Forum - 10-14-2012

[eluser]alexwenzel[/eluser]
I massivly enhanced the SMC wiki. Have fun using it.


SMC - Simple Model for CodeIgniter (CRUD) - El Forum - 10-26-2012

[eluser]jojo777[/eluser]
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!


SMC - Simple Model for CodeIgniter (CRUD) - El Forum - 10-31-2012

[eluser]alexwenzel[/eluser]
[quote author="jojo777" date="1351242612"]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![/quote]

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

I need some feedback to improve usability.