simeon2000 has asked for the wisdom of the Perl Monks concerning the following question:
I've got 2 packages in separate pm modules so far: TArtLib and TArt::Editor (it's for TalkArticles... TArt seemed cute :P). TArtLib holds a $dbh database connection handle and uses DBI. TArt::Editor is just a data object with accessor methods. What I want is for my TArt::Editor to use the DBI connection ($TArtLib::dbh) from the TArtLib program, so it doesn't have to use DBI and make the connection for every Editor Data object I create. That way TArt::Editor can populate itself with the data for an editor by itself, instead of having arguments passed to it to populate them.
I know Apache::DBI will keep the DB connections going (It's running in mod_perl), but I'm wanting it to do it from the command line as well. I'm just not sure how to get TArt::Editor to get TArtLib's DBI connection. BTW, TArtLib will always be called before TArt::Editor, if that helps.package main; use TArtLib; use TArt::Editor; my $lib = new TArtLib; # This object would populate itself from the database, # using the number passed to it as the primary key, # and hopefully using TArtLib's DBI connection. my $ed = new TArt::Editor(1); print $ed->{NAME}; # etc. etc.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: OOP Access of variables
by TheoPetersen (Priest) on Mar 08, 2001 at 21:27 UTC | |
by simeon2000 (Monk) on Mar 08, 2001 at 21:35 UTC | |
by TheoPetersen (Priest) on Mar 08, 2001 at 21:38 UTC | |
by simeon2000 (Monk) on Mar 08, 2001 at 22:02 UTC | |
by Masem (Monsignor) on Mar 08, 2001 at 22:46 UTC | |
|
Re: OOP Access of variables
by Masem (Monsignor) on Mar 08, 2001 at 21:22 UTC | |
by simeon2000 (Monk) on Mar 08, 2001 at 21:27 UTC | |
by simeon2000 (Monk) on Mar 08, 2001 at 21:29 UTC |