RE: [PEAR] Testing for instance of pear DB.

From: Date: Wed, 17 Apr 2002 08:21:00 +0000
Subject: RE: [PEAR] Testing for instance of pear DB.
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-1151@lists.php.net to get a copy of this message
On Wed, 2002-04-17 at 00:56, Pierre-Alain Joye wrote: > > There is currently no rock solid way, because they all depend on > > implementation details, but here's a suggestion: > > > > if (is_object($obj) && > > get_parent_class($obj) == 'db_common' && > > method_exists($obj, 'simpleQuery')) { > > } > pear::auth used this method, the problem of testing parent object is you do > not allow users to create his own classes ( with a compatible interface ). > > Personnaly, I will greatly appreciate a test function in the DB interface. > if (is_object($obj)) > { > if ( method_exists($obj,'isDB') ) > { > } > } > > just an idea :) I just added DB::isConnection() in CVS, it will allow people to subclass the drivers too. - Stig

« previous php.pear.general (#1151) next »