On 12/5/06 11:08 AM, Michael Lackhoff wrote: > On 5 Dec 2006 at 10:32, John Siracusa wrote: >>>> sub generate_invoice_number >>>> { >>>> my $class = shift; >>>> my $db = My::DB->new; # Rose::DB subclass >>> >>> Why not just use the default here? >> >> What default? > > The one that is inherited from my common base class (I followed the tutorial > [1] except that I don't have separate manager classes) through init_db.
Ah, I didn't know you had combined the manager methods into your RDBO-derived class. Anyway, like I said, get the db from wherever you want. The important part is to share it among all the queries that are used to lock, get new invoice id, and unlock. > Is it ok then to just define init_db once in the base class and never add a > 'db' parameter in special purpose methods? I thought if no 'db' is given, the > one from init_db is used in every search. Yes, if your implementation of init_db() always returns the same db object to all callers, you should be okay. That said, I think the more explicit approach is a bit more clear, in case you (or someone else) ever change init_db() and then forget to find every place in the code that assumes init_db() will always return the same db object :) -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