For Programmers: Free Programming Magazines  


Home > Archive > PHP DB > May 2004 > Re: [PHP-DB] Extending Pear DB class. Is it possible?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: [PHP-DB] Extending Pear DB class. Is it possible?
Robert Twitty

2004-05-17, 12:30 pm

It appears that you want to extend DB_coomon not DB. The reason is because

$dbh = MyDB::connect( $dsn );

returns an instance of the DB_common class. However, DB_common is the base
class for writing a PEAR DB driver class. And, what is really returned by
DB::connect() is an instance of the driver class that extends DB_comon.
Creating a MyDB_Common will not work either, unless you edit all the DB
database driver class files to extend MyDB_common instead of DB_Common. If
you are doing this for a specific database, then what you should is extend
the corresponding driver class, i.e, mymysql.php. You would then use
'mymysql' instead of 'mysql' as the driver name.

What functionallity do you wish to add to DB?

-- bob

On Mon, 17 May 2004, Ross Honniball wrote:

> Hi all,
>
> I'd like to extend the standard Pear DB class, but there is something a bit
> curly about it.
>
> PHP lets me create a class like:
>
> class mydb extends DB { functions etc. }
>
> however the new class mydb will not include all the functions. I think it
> is only including all the functions defined in the 'common.php' file.
>
> The 'mydb' class above won't, for example, have the 'query' function, even
> after successfully connecting to a database.
>
> Anyone know how to go about extending the Pear DB class?
> .
> . Ross Honniball. JCU Bookshop Cairns, Qld, Australia.
> .
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com