in reply to Re: How can I avoid creating two instances of the same object
in thread How can I avoid creating two instances of the same object

I have tried that as well. That works as far as limiting one $dbh but I still have to call new for every table I create. Some of the scripts may access over 30 tables. That would mean that I would have to call new over 30 times and that is what I'm trying to avoid. What is the best method for only having to create one object then use that object over without having to call new each time I access a new table.
  • Comment on Re^2: How can I avoid creating two instances of the same object

Replies are listed 'Best First'.
Re^3: How can I avoid creating two instances of the same object
by adrianh (Chancellor) on Mar 02, 2006 at 15:56 UTC
    What is the best method for only having to create one object then use that object over without having to call new each time I access a new table.

    Pass the $dbh to each new()?

    You might also want to look at dependency injection techniques, see IOC for one way to go about them.