Database Object Access

Your code modifications and patches you want to share with others.
Locked
User avatar
fornve
Joomla! Apprentice
Joomla! Apprentice
Posts: 6
Joined: Wed Dec 16, 2009 1:42 am
Location: Rotherham/UK
Contact:

Database Object Access

Post by fornve » Wed Dec 16, 2009 6:57 pm

Hi Everyone,

Maybe someone else will find this usefull.

In all my Joomla! projects if I have to create new tables, I use DAO layer.

For example if I want to deal with table jos_content (or any new) I create entity class for it:
http://github.com/fornve/Joomla--DAO/bl ... .class.php

To retrieve by $content_id:

Code: Select all

$content = Content::Retrieve( $content_id );
$content->title = 'New title';
$content->Save();
Or create new one

Code: Select all

$content = new Content();
$content->title = 'New content';
$content->Save();
There is possible to add extra methods to entity classes, and on Retrieve.
There is one crazy example of entity class:
http://github.com/fornve/Sum-e.com-shop ... .class.php

It is really usefull.

Project repository:
http://github.com/fornve/Joomla--DAO

Just seeded, I haven't decided yet where is best place for entities directory. I am Joomla! beginner ;)

Any comments welcome.

User avatar
fornve
Joomla! Apprentice
Joomla! Apprentice
Posts: 6
Joined: Wed Dec 16, 2009 1:42 am
Location: Rotherham/UK
Contact:

Re: Database Object Access

Post by fornve » Mon Jan 04, 2010 3:30 pm

I am proud to release Joomla Dao Plugin - for Joomla! 1.5 and 1.6

Download latest:
http://sum-e.com/resources/files/joomla-dao-plugin.zip

More about:
http://sum-e.com/Page/View/2/Joomla%20DAO

This plugin does it for you. Makes code cleaner, even more objcet orientated and speeds up development a lot.
Also I recommend it to all Joomla! Developers who are not bothered escaping input strings (JDatabase::getEscaped) Entity::Save does it for you.
You do not have the required permissions to view the files attached to this post.


Locked

Return to “Core Hacks and Patches”