Extending a class with a static constructur (like PEAR::DB)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



So... I'm trying to extend PEAR::DB. It'd be great to keep everything it offers and just add a few more perhaps unconventional functions. 

Intuitively, it seemed like this approach might work:

<?PHP

    require_once("DB.php");

	# Toy Extension of DB Class
    class DBToyExt extends DB
    {
        var $foo = 1;
        var $bar = 2;

        function testext($x)
        {
            echo "\nHEY: $x";
        }
    }

    $dte = DBToyExt::connect("mysql://weston_tssa:******@localhost/weston_tssa");

    $dte->testext('testing');
    $dte->testext($dte->moo);
    $dte->testext($dte->bar);

?>  

However, it doesn't seem to understand that the method "testext" exists, and gives me a fatal error to that effect, as you can see:

http://weston.canncentral.org/web_lab/mlib/DBToyExt.php

I'm guessing this is a side effect of the static constructor -- apparently using the "extends" keyword is enough to help the engine know that the class DBToyExt is supposed to inherit the static function "connct", but it's not enough to bless the return value of connect from the class DB to DBToyExt....

How do I get around this and extend DB?

Thanks,

	Weston

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux