in reply to OO Perl: classes and database access

Your question is addressed exactly by Class::DBI. It is particularly good at translating database relationships into object methods, so your users and projects question all but disappears. Assuming you have a Class::DBI class for each of user and project, put this in the My::User class:

__PACKAGE__->hasa_list( 'My::Project', ['name_of_field_in_project_table'], 'projects', );

And then to retrieve the projects all you have to say is:

my $user = My::User->retrieve($id); my @projects = $user->projects();

I use it all the time and i can't recommend it highly enough.

Replies are listed 'Best First'.
Re: OO Perl: classes and database access
by fx (Pilgrim) on Oct 03, 2001 at 16:17 UTC

    Thanks for the suggestion, Class::DBI is working well for me now.

    fx