TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Advanced PHP Programming (http://www.talkphp.com/advanced-php-programming/)
-   -   Constructor in an abstract class? (http://www.talkphp.com/advanced-php-programming/1662-constructor-abstract-class.html)

bdm 12-07-2007 09:15 PM

Constructor in an abstract class?
 
Is it safe to do the following:
PHP Code:

abstract class Db_Adapter_Abstract {
    public function 
__construct($config) {
        
$this->connect($config);
    }

    abstract protected function 
connect($config);


It works since I've tested it. But I have this funny feeling on how it shouldn't be done. Since all my database adapters will have a common constructor, I figure it's alright to do.

What are your thoughts?

Thank you.

Karl 12-07-2007 09:30 PM

That's perfectly fine, it's the logical place to put such code :-)

bdm 12-07-2007 09:59 PM

Perfect!

Thank you. :)


All times are GMT. The time now is 08:30 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0