CodeIgniter Forums

Full Version: How badly do we want ORM?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3

El Forum

[eluser]Derek Allard[/eluser]
ORM is one of the things that we've publicly stated is on the radar. At this point though, Cake's ORM is more mature then ours.

James Nicol, who used to be really active, but lately has been bogged down with other stuff, has written up some useful stuff on his site also. Just visit the front page and you'll see a bunch of CodeIgniter articles.

El Forum

[eluser]garymardell[/eluser]
Anyone checked out, http://ioreader.com/2007/06/26/active-re...framework/

and

http://ioreader.com/code/ORM%20Documentation/index.php

for its documentation

El Forum

[eluser]esra[/eluser]
[quote author="gunter" date="1184530343"]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)[/quote]

You can't just drop Doctrine in a directory and expect it to work. You need to write a new DBO to integrate Doctrine with CI and will most likely need to write a new Model library. The Model method in Loader may have to be overloaded (not sure about this without looking).

The better way of handling this is to write a new PHP5 DBO based on the use of PHP5 interfaces and write one interface for each supported DBAL, including the CI DBAL. To automate interface loading, you can create an interface parameter for the database.php config. Most ORMs are dependent on a specific DBAL--Doctrine needs PDO, Propel needs Creole, etc. Then adding support for new DBALs (and their associated ORMs) would be a matter of writing a new interface.

El Forum

[eluser]esra[/eluser]
[quote author="Derek Allard" date="1187233691"]ORM is one of the things that we've publicly stated is on the radar. At this point though, Cake's ORM is more mature then ours.

James Nicol, who used to be really active, but lately has been bogged down with other stuff, has written up some useful stuff on his site also. Just visit the front page and you'll see a bunch of CodeIgniter articles.[/quote]

Most ORMs are dependent on a specific database abstraction layer (DBAL). For example, Doctrine is dependent on PDO but uses its own DBAL (which is also the basis for the PHP6 DBAL), Propel is dependent on Creole, etc. If the DBO was rewritten to support multiple DBALs, adding support for multiple ORMS would be much easier. Granted that Rick needs to remain Base4/5 for the time being, but if there is interest in moving to Base5/6 later down the road, I might have something to show. Some model abstraction becomes necessary especially with regard to Propel.

Elsewhere in one of his posts, I recall that Rick based the syntax for CI's database abstraction layer on ADODB. I'm wondering if he also based his AR and Transactions support on ADODB which actually uses the Table Gateway Pattern rather than AR. PDO is fast because the PDO extensions are written in C. When you compare apples and oranges, ADODB with Jon Limb's C extension is faster than PDO (about 90-100% faster than ADODB without the extension). Thus, I'm beginning to wonder if Canglan's ORM solution might have more usefulness than currently meets the eye.

El Forum

[eluser]Derek Allard[/eluser]
Good points esra, I wish I had god answers for you, but truthfully I'm not sure what Rick based the original on, or what future plans are at this stage. Thanks for this useful post.

El Forum

[eluser]Rick Jolly[/eluser]
gunter, I've been playing with Doctrine. Maybe I can help if you are still in need?

El Forum

[eluser]gunter[/eluser]
oh yes please, Rick! (Sorry, haven´t seen your post until now)

I had problems to get the whole system to run. (Some class not found errors)
I tried doctrine 2 weeks ago, and I cannot find now my nonworking scripts but I remember, I had some class not found errors.
I will try again at the weekend and if I still have no success than I will call you, okay?

El Forum

[eluser]Rick Jolly[/eluser]
Sure, PM me if you like.

Some things that might help:

1) If you put the Doctrine stuff in your libraries folder, include it in your scripts like this:
require_once(APPPATH . '/libraries/doctrine/lib/Doctrine.php');

2) I took the advice of the user manual and "compiled" it. That solved a lot of problems because then I didn't need to set the include path or use the spl_autoload_register(array('Doctrine', 'autoload')); function. To compile it, just include Doctrine.php like in step #1 above, put this in your script: Doctrine::compile();, and run the script - it takes some time. Now you can include the compiled version of Doctrine and all the common classes will be automatically included by using:
require_once(APPPATH . '/libraries/doctrine/lib/Doctrine.compiled.php');

3) Remember to include your database object classes. I put mine in a doctrine folder in the models folder so my includes looked like this: require_once(APPPATH . '/models/doctrine/MyClass.php');

A beta release is due Aug 31, so things may change soon.

El Forum

[eluser]gunter[/eluser]
thanks! I will do it like that!
And I found a very detailed Tutorial in german, I will follow it step by step! here´s the link if someone can read german: doctrine tutorial

El Forum

[eluser]enginedave[/eluser]
I have downloaded the example application from www.glossopteris.com which provides a library to aid in the management of table relationships. I followed the instructions to the letter in a fresh codeigniter installation.

However I get loads of php errors stating
Code:
A PHP Error was encountered

Severity: Notice

Message: Undefined variable: array

Filename: libraries/table.php

Line Number: 131
I am using php5 on local host - any suggestions as to the problem.
Pages: 1 2 3