RE: [PEAR] Testing for instance of pear DB.
| From: | Pierre-Alain Joye | Date: | Tue, 16 Apr 2002 22:56:17 +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-1150@lists.php.net to get a copy of this message | ||
> 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 :)
pa