in reply to dependencies and loose coupling

You don't need to set up the database connection in the base class. All you need to do is make sure that the connection routine for your base class is called before you attempt to create any objects that have a database existance.

That means your script is free to do however much processing it needs to do before you set up the connection.

Like this:

use Music::DBI; use Music::Artist; yadda(); yadda(); yadda(); # where yadda does not touch the database Music::DBI->connection('dbi:mysql:$dbname,$user,$pass); $art=Music::Artist->create(.....) # etc

Replies are listed 'Best First'.
Re: Re: dependencies and loose coupling
by perrin (Chancellor) on May 12, 2004 at 22:09 UTC
    I have to set it before the subclasses get compiled, because it's inheriting from Class::DBI::mysql and using the setup_table method, which requires a database connection to run.