in reply to Writing Better Objects

I am in love with Class::DBI and Class::DBI is in love with me.
package User; # read the docs for why not to sub-class exactly like this use base Class::DBI::mysql; __PACKAGE__->set_db('Main', 'dbi:mysql:dbname', 'user', 'password'); __PACKAGE__->set_up_table( 'USERINFORMATION'); 1; # In your program package main; use User; my $howmany = User->count; my $user = User->search(username => $_[0]); print $user->userid; print $user->username; #update username $user->username('Biff'); $user->update;
--
Clayton aka "Tex"

Replies are listed 'Best First'.
Re: Writing Better Objects
by Anonymous Monk on Jun 20, 2003 at 04:44 UTC
    Ive got a possible solution, dbClassBuilder

    It's a small project i coded up a while ago, that ive started looking at again.

    It has a perl script that parses a simple sql schema, and feeds the hashref representation to an HTML::Template driven template to create the Class modules.

    It's fairly easy to create your own templates, in your own favoured style for whatever language you like.

    The advantage of preproducing the code is that you can delete unneeded functions and tweak code for specific needs.

    I have plans to create a more complex meta language, that can handle foreign keys and other relationships.

      It sounds like you're recreating Alzabo except that its already written. It does exactly that.