Beefy Boxes and Bandwidth Generously Provided by pair Networks DiBona
Syntactic Confectionery Delight
 
PerlMonks  

Re: OOP Access of variables

by Masem (Monsignor)
on Mar 08, 2001 at 16:22 UTC ( [id://63016]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to OOP Access of variables

I think I'm missing something here, but isn't this as easy as making sure that TartLib's dbi connection variable is in the EXPORT list, or you provide a function that returns it if you want better encapsulation?: eg...
my $sth = TArtLib::dbi->prepare("select * from table") or die DBI::err +str; my $sth2 = TArtLib->dbi()->prepare("select * from table") or die DBI:: +errstr;
What's confusing is that you say you want it from the persistent connection from the command line as you'd get from running Apache::DBI. Unless you have an aspect of your program that will be running constantly acting as a server, I don't see how you can get this, as TArtLib will be initialized every runtime from the command line, reconnecting it to the database. Maybe I'm just mistaken here.
Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain

Replies are listed 'Best First'.
Re: Re: OOP Access of variables
by simeon2000 (Monk) on Mar 08, 2001 at 16:27 UTC
    Sorry, I must not have made it clear.

    I mean, each time the main script is run, I only want one instance of the database connection. This is created in TArtLib ($TArtLib::dbh).

    I want TArt::Editor to be able to use $TArtLib::dbh, so that TArt::Editor doesn't need to make a new DB connection. Both TArtLib and TArt::Editor will/should always be used in package main.

      ... the reason being, if I have 40 editor objects, I don't want 40 database handles. I'd like all 40 TArt::Editor objects to use TArtLib's DB connection.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://63016]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.