Re: [PATCH] DB::connect(): stuff that should be in DB::factory()

From: Date: Sun, 21 Sep 2003 20:29:57 +0000
Subject: Re: [PATCH] DB::connect(): stuff that should be in DB::factory()
References: 1 2 3  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-21869@lists.php.net to get a copy of this message
# neuhauser@bellavista.cz / 2003-06-03 15:14:05 +0200: > # cox@idecnet.com / 2003-06-03 14:27:05 +0200: > > From: "Roman Neuhauser" <neuhauser@bellavista.cz> > > Subject: [PEAR-DEV] [PATCH] DB::connect(): stuff that should be in DB::factory() > > > > > DB::connect() uses DB::factory() to instantiate the appropriate > > > class. > > > > > > Body of factory() was replaced with instantiation code from > > > connect() (better error message, etc). > > > > > > factory() now takes two arguments, the second being $options > > > (passed through from connect()); it's used just as it used to be in > > > connect(). > > > > DB::factory() was nice for me to test parseDSN() ... but appart of it, why > > would DB need to provide factory()? > > well, that's not for me to judge as I don't know all the ways people > use PEAR::DB. but the code is there, and it should be either > maintained or removed. letting it bitrot is not a good idea. There's grown such a need since then: a team I am a member of uses subclasses of the DB class, and some of its drivers. The DB subclass basically just redefines the DB::connect() method, and the gist of the change is that first looks for the driver in a custom directory before falling back on the default driver implementation. ~10 lines added, ~40 copied. The code duplication could have been reduced hadn't the factory method been left to bitrot. -- If you cc me or remove the list(s) completely I'll most likely ignore your message. see http://www.eyrie.org./~eagle/faqs/questions.html

« previous php.pear.dev (#21869) next »