in reply to How can I avoid creating two instances of the same object
Have a singleton hold your database connection (roll your own or use something like Class::Singleton). The User and Company classes use that singleton to get access to the database handle.
Keep in mind, however, that there may be reentrancy issues if (for example) you need to have multiple active statement handles simultaneously (depending on your database, and presuming you're using DBI).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How can I avoid creating two instances of the same object
by beachguy82 (Novice) on Mar 02, 2006 at 03:54 UTC | |
by Fletch (Bishop) on Mar 02, 2006 at 13:55 UTC |