On Tue, 21 Nov 2000, Ilya Soldatkin wrote:

> I  am creating an object that make queries to database. But how shall I
> explain to him what database handler he shall use?
> Under mod_perl it is too dangerous to make $dbh global variable.
> Well, I can create data field in this object that will store current $dbh,
> but it seems too strange too me to have such data field in object:
> 
> $person={
> name=>'Jack',
> age=10,
> ...,
> $dbh=>...
> }
> 
> $dbh have no relation to information about Jack.
> Is there any better solution?

This really has little to do with mod_perl, more about object design. You
should get yourself a book about OO design. Or you can use a Singleton
(see Class::Singleton on CPAN, or write your own Singleton module - its
only about 10 lines of code).

-- 
<Matt/>

    /||    ** Director and CTO **
   //||    **  AxKit.com Ltd   **  ** XML Application Serving **
  // ||    ** http://axkit.org **  ** XSLT, XPathScript, XSP  **
 // \\| // **     Personal Web Site: http://sergeant.org/     **
     \\//
     //\\
    //  \\


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to