Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter ORM
#1

[eluser]Ben Edmunds[/eluser]
Hey guys,

Just a question or maybe a poll per say. I'm getting deeper into CodeIgniter and have started looking into the different ORM solutions, so:


Who uses an ORM with CodeIgniter? If you do, which ORM? What are your likes/dis-likes?



Thanks,
#2

[eluser]BrianDHall[/eluser]
All about the DMZ, baby. Its one of the big reasons I use CI, actually, as I was strongly considering going to something else that offered ORM as I heard it was such a good tool.

I have no real complaints, and there is much to like.

For one, it's easy to setup once you get the hang of the naming conventions. I beat the drum all over these forums so you can probably search for Briandhall and DMZ and get plenty of results Big Grin

Accessing relations are very easy, such as:

Code:
$user = new User();
$user->where('username', 'tester')->get();
$user->usergroup->get();
$user->usergroup->accessrole->get();

Now you have a user object with all the values of it's entry in the database (DMZ takes info directly from DB, you don't have to configure any columns or anything like that - just table and model relations), you have the usergroup the user is a part of, and you have all the access role rules that usergroup has.

Its all built over CI's built-in ActiveRecord class, so its very familiar and maintains the same flexibility and ability to fall back to manual queries if you absolutely must (I haven't had to, but it's nice to know I can).

Another huge plus for me is the Array and HTML Form extensions I'm still playing with.

This ties in with another benefit of DMZ - it permits you to do all data validation in the model itself. So you can set passwords to be trimmed and encrypted before saving in a database, encrypt/decrypt credit cards using your own private-key/public-key encryption functions, make sure things only contain certain letters or are numeric - in short, everything the underlying form validation class of CI offers.

However by doing all this in the model it requires much less code duplication - I haven't used a single set_rule call since I started using it.

The side-effect of this not considered in the original Datamapper is that if you have a system that knows all about your database fields and relations...why can't it make form building and propagating much easier? Thus the Array (so you can set all the fields in your database and set them against POSTed fields with one line of code) extension, and HTML form extension allows automated dynamic building of HTML forms as well.

I have only now begin to get into those extensions and I loved DMZ before that - they are just some sweet, sweet chocolate icing on the already indulgant chocolate cake that it is.

Mmmm...ORM...creamy...
#3

[eluser]cahva[/eluser]
DMZ user here also. Same words than BrianDHall says. It simply rulez! Smile Theres really nothing I can think of that I dislike in it. Overzealous(and ofcourse the original author) has done a really good job and it just keeps getting better and better all the time.




Theme © iAndrew 2016 - Forum software by © MyBB