Re: [OT] Abstract-Database Class
by Eric Prud'hommeaux other posts by this author
Aug 7 2000 12:32PM messages near this date
view in the new Beta List Site
RE: [OT] Abstract-Database Class
|
RE: [OT] Abstract-Database Class
On Fri, Jul 28, 2000 at 08:33:57AM -0700, Michael Nachbaur wrote:
> <Warn priority="low">
> <warning class="Off Topic"/>
> <warning class="Long"/>
> </Warn>
>
> I'm not exactly sure where to send this, but here it goes:
> Has anyone completed/started an abstract database class at all? I've written some for ver
y specific applications, but I want a more general-purpose tool. I'm about to start develop
ment on one, but wanted to get feedback from the world-at-large to see what features you wou
ld want first (or if anyone has already started one).
>
> The classes I've created/used before, are like:
> my $order = new Order( oid => '1234567' );
> $order->fetch();
> foreach my $order_line ( $order->Lines ) {
> print $order_line->Description, $order_line->Price;
> }
>
> I'd like to interact with a database, update data, save data, etc. without having to actu
ally call any SQL code. And, if I modify my database schema, I'd like the classes to automa
tically adapt.
>
> The way I've done this before, is create a series of classes with AUTOLOAD subs in them wh
ich intercept the name of the method being called, and then updating that specific field in
the record.
>
> How I"d like to implement it would be to define an XML file with represents the way my dat
a is structured in the database. This way, the objects can determine when to cache data, an
d when to commit its values to the database for maximum efficiency. An example could be:
I have an object database abstraction that I use for a bunch of stuff, including a set of RD
F libraries. "object" is a perl datastructure defined by an SQL table. The purpose of Object
DB is to allow programs to store objects, create objects, load objects from the DB (includin
g all objects linked via external keys) and cache the DB interactions to keep it all efficie
nt. The bulk of the work is in an importer that reads a database structure and generates a .
pm with class defs, and a bunch of code for handling the implications of unique indexes.
Take a look at http://www.w3.org/1999/02/26-modules/ and http://dev.w3.org/cvsweb/perl/modul
es/W3C/Database/ to see if you are interested in leveraging off ObjectDB or just ripping off
code.
--
-eric
(eric@w3.org)
Thread:
Michael Nachbaur
Eric Prud'hommeaux
|