470,848 Members | 959 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,848 developers. It's quick & easy.

Extending a PEAR class

Hi All,

For a project I'm working on I wanted to be able to add extra
functionality to Pear's DB class. I can add the functionality as
stand-alone functions, but as they were to do with the database
connection I thought it would make sense to wrap them up into a class
that extended the Pear::DB class.

So, I whipped this up to test:

require('DB.php');
class BobDB extends DB {
function myfunction($param) {
return true;
}
}

$bobdb = bobdb::connect('mysql://root@localhost/mydb');
return $bobdb->myfunction('hello');

PHP liked that in terms of syntax but the reference to myfunction
returned "Fatal error: Call to undefined function: myfunction()"

Now I know this problem is something to do with calling the PEAR::DB
class statically (using the :: operator) but I'm not sure how to get
around it.

I tried going down the $bobdb = new bobdb(); path but got lost with how
PEAR creates it's own instances of it's classes.

Any help appreciated.

Cheers,

- Bob -

--
Bob Brown, Web guru etc
http://www.guru.net.nz/
Jul 17 '05 #1
0 1329

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Arne Kösling | last post: by
3 posts views Thread by Sandro Dentella | last post: by
13 posts views Thread by Wolfgang May | last post: by
1 post views Thread by DJ Majestik | last post: by
3 posts views Thread by David | last post: by
1 post views Thread by webguynow | last post: by
reply views Thread by Samuel Zallocco | last post: by
5 posts views Thread by vbgunz | last post: by
1 post views Thread by CSTechie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.