On 2/26/07, Adrian Howard <[EMAIL PROTECTED]> wrote: > On 26 Feb 2007, at 08:28, Jud wrote: >> I'm not sure how to get Rose to use only a single database object for all >> classes and objects. I am looking for a better way than to create a new >> Rose::DB object at the beginning of every script, and then pass it to each >> object as it gets created using MY::Object->new(db => $MY_DB, ... ) for >> every one. [...] > > Add a init_db() method to a common subclass that returns the DB > object that you want to use?
Yep, that's the way to do it: package My::DB::Object; # common base class use base 'Rose::DB::Object'; use My::DB; our $DB; sub init_db { $DB ||= My::DB->new(...) } -John ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object