RE: [PEAR] extending pear db
| From: | patrick dot allaert at belgacom dot be | Date: | Mon, 27 Oct 2003 12:03:48 +0000 |
| Subject: | RE: [PEAR] extending pear db | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-8611@lists.php.net to get a copy of this message | ||
Hello,
everything depend on what you want to do, you will be able to do:
a_db::foo();
to call the function foo of the derived class, but this is a class function call !
probably the easiest way is to extends the class DB_mysql itself !
however it is not really efficient/elegant since you have to inherit from each DB_* class to add
your "foo()" function
If you just want to add a function to MySQL connection, try this:
class DB_mysql_a extends DB_mysql {
function foo() {
}
}
(you will have to save this file as this: "PEAR_DIRECTORY/DB/mysql_a.php")
and when connecting, use a dsn like: "mysql_a://login:pass..."
Patrick Allaert
-----Original Message-----
From: Ámon Tamás [mailto:sajt@amon.hu]
Sent: 27 October 2003 12:12
To: pear-general@lists.php.net
Subject: [PEAR] extending pear db
Hi!
I like to extend pear db. I made something like this:
class a_db extends DB
{
function a_db(){
//itt valami
}
function foo(){
}
}
and after call this:
$db = &a_db::Connect($_config['dsn']);
But when I try to call
$db->foo();
I get the message:
Call to undefined function: foo();
I think this is because the $db is a DB_mysql object.
How van I solve this problem?
Thanks in advance and sorry for my poor english.
--
Tamás Ámon <sajt@amon.hu>
--
PEAR General Mailing List (http://pear.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php