CodeIgniter Forums
How badly do we want ORM? - 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: How badly do we want ORM? (/thread-2014.html)

Pages: 1 2 3


How badly do we want ORM? - El Forum - 07-11-2007

[eluser]Unknown[/eluser]
Just how badly is ORM wanted by the CI community? I have been working on a very simple helper that would "bolt on" ORM. It seems very promising, although it's a long way to alpha.

However, it does appear that the overhead of creating objects out of rows in an array is significant. I'm using lazy instantiation to avoid objectifying any particular result until directly called, but this still adds quite a bit of overhead. My initial tests show a slightly exponential increase in load times as the number of records increases. At ten records, the difference between standard array iteration and iteration with instantiation is not noticeable- in fact, sometimes with ORM proved to be faster (almost certainly due to other processes going on in the environment). At 100 records, the difference is in hundredths of a second. At 10,000 results, the difference is just under a 100% increase in load time.

The alternative is to have a function wrapper that accepts a row as input and manually generates an object. The disadvantage is that this would not be able to introspect if the result already exists, and would not be able to have a universal save() method without an extra parameter being passed to the wrapper function. However, this would allow native speeds and only instantiate where specifically needed.

After having several people look over the code (which is very bare bones at this point- it's simply a wrapper class) and trying a few techniques and methods to iterate (tail recursion, for and foreach iteration, etc.), the trend in load times seems to equal out across the board. I think the problem is simply the overhead of PHP objects (as they were sort of "bolted on" as well).

So, do you guys think it's worth continuing and creating a finished product that can be added into a project? For your uses of CI, is that an acceptable overhead?


How badly do we want ORM? - El Forum - 07-11-2007

[eluser]Rick Jolly[/eluser]
There are so many mature ORM options available:

1. DB_DataObject
2. EZPDO (php 5 only)
3. Propel (php 5 only)

Personally, I don't see the point in creating another unless it offers something different. It would be a monumental task to create a complete ORM from scratch. A tutorial for using an existing ORM within CI would be valuable though.


How badly do we want ORM? - El Forum - 07-11-2007

[eluser]Unknown[/eluser]
Most likely, no outside ORM will use CI's db library or active record class. And Propel (if I remember it correctly) in particular is an inelegant solution, in that it uses XML to describe models (which is elegant when talked about but inelegant to program with). I was not actually talking about modeling data- CI already has models. I was talking about extending data objects to make them more expressive to work with. Granted, this does not fully embody the paradigm of ORM, but then again, CI doesn't embody the full paradigm of MVC.

PHP is not an extremely expressive language to use for modeling, anyway. It's kind of a web templating tool for Perl that got away from its authors Smile

Anyway, my tactic is to prototype a basic result struct for each row returned that would have methods for saving, deleting, and finding related records across relationships, introspected from the query itself.


How badly do we want ORM? - El Forum - 07-12-2007

[eluser]gunter[/eluser]
I just want say, there is another orm library named
Doctrine


How badly do we want ORM? - El Forum - 07-15-2007

[eluser]gunter[/eluser]
has someone tried Doctrine and can help me?
I want try it, but cannot download it - the download link is broken and the other download possibility is via svn, that I donĀ“t know to use...

maybe someone can mail me the zipped package? (please ask first)


How badly do we want ORM? - El Forum - 07-17-2007

[eluser]Unknown[/eluser]
LuTze,

I would love native ORM in CI. I've been pining for it badly over the last couple of days and I've been keeping a project halted while I decide between CI and the CakePHP framework (which has ORM built in).

Cake is too bloated and restrictive for me though and I don't think even ORM is worth the switch.

For me, CI would be complete with relational models!

- Nick


How badly do we want ORM? - El Forum - 08-15-2007

[eluser]gunter[/eluser]
finally I could download doctrine, but its the pure horror, so complicated to setup, at least it seems to me - and nobody there at there forum to help


How badly do we want ORM? - El Forum - 08-15-2007

[eluser]fredwu[/eluser]
I honestly don't understand why most of the ORM solutions are so complicated.

I'm currently building a rather large application, and if I decided to use CI, I'll then rebuild my simple ORM library. Wink


How badly do we want ORM? - El Forum - 08-15-2007

[eluser]esra[/eluser]
[quote author="gunter" date="1187199136"]finally I could download doctrine, but its the pure horror, so complicated to setup, at least it seems to me - and nobody there at there forum to help[/quote]

Doctrine got a Google Summer of Code 2007 project and some major refactoring is underway to make the API more modular and robust. Other changes are also underway to get ready for PHP6. The documentation needs some serious work, but that will probably have to come later after the number of developer commits drops to a reasonable level.


How badly do we want ORM? - El Forum - 08-15-2007

[eluser]thurting[/eluser]
ORM would be nice - would def. speed development.