So, I'm a little confused now and I don't reall want to add additional
noise to the development of the JQuery class or disregard the valuable
work already done, but I feel compelled to point out the following.
The confusion is regarding the intentions of an ORM for Joomla. Back
some time I googled "joomla +orm" and found that this was something
being worked on, and its name was JODA (
http://developer.joomla.org/
gsoc2008/multi-db-support.html). But recently thanks to twitter I got
to know through Rob Schley that this project is not active anymore,
some further research and I found this:
http://forum.joomla.org/viewtopic.php?f=326&t=195747&sid=daa718d9c34e75dde246cf0cb98d6081&start=150
There is also a couple of things in stake here, when considering an
ORM implementation for Joomla this is: database abstraction and query
building. A custom ORM for Joomla might be the best option but there
is just so much to be done...
I've been working with the open source Doctrine ORM along with Joomla
for some time, and it feels quite natural. The Doctrine framework has
some really beautiful engineering behind, it includes database
abstraction and object oriented SQL (called DQL). Check them out at
ohloh
http://www.ohloh.net/p/doctrine.
So, if we ever have an ORM for Joomla I think this is a great option
that would save the dev team a lot of work. Best of all, it is really
easy to integrate, just take a look at this pastie of my component
entry point:
http://pastie.org/499691. The previous loads the models
in the environment and I can just do stuff like this for a save()
function:
$currency = new Currency();
if($id = JRequest::getVar('id')){
if($record = Doctrine::getTable('currencies')->find($id)){
$currency = &$record;
}else{
JError::raiseWarning(0,JText::_('RECORD_NOT_FOUND'));
$this->cpanel();
return;
}
}
$currency->name = JRequest::getVar('name');
$currency->symbol = JRequest::getVar('symbol');
$currency->status = JRequest::getVar('status');
try{
$currency->save();
JFactory::getApplication('site')->enqueueMessage(JText::_('SAVED'));
}catch(Exception $e){
JError::raiseWarning(0,JText::_('NOT_SAVED').': '.$e->getMessage());
}
You can take a look on the whole controller over here:
http://pastie.org/508324.
Notice no models are being used.
I have some other projects in the stack and I sincerely intend to keep
using Doctrine instead of using JTable or any other classes... because
it is just better to use an ORM for most cases.
Integrating Doctrine as an external library would imply but not
limited to the following:
* Dealing with file and directory structure conventions for the
generated models, YAML definitions, etc...
* Refactoring and Integrating with JDatabase, JRecordSet, JModel,
JController, JQuery... etc.
* Tuning Doctrine's configuration accordingly for Joomla. An example
of this:
http://pastie.org/508338
* Taking advantage of advanced functionality in the Doctrine such as
record hydration, paging, relations, etc.
The framework is exceptionally rich, beautifully designed, exception
driven and considers DBMS specific cases, very well documented and
nice developer support.
You can find the API here:
http://www.doctrine-project.org/documentation/api/1_1
Manual and other documentation here:
http://www.doctrine-project.org/documentation
There is of course a risk of relying heavily on a framework for such
an important task as this, however I find it to be the best supported
ORM framework for PHP and there is a version 2.0 coming with lots of
really delicious featurues thanks to the new technical commodities
that PHP 5.3.0 is bringing.
Could this be possible for, say, Joomla 1.7?, if not, are there any
SERIOUS plans for an ORM in the Joomla Framework?. Either way I think
there is so much to learn from Doctrine's design,
put special attention to this:
http://www.doctrine-project.org/documentation/manual/1_1/en/technology
Thanks for your time