Re: Extending PEAR::DB (static constructor issue?)

From: Date: Fri, 10 Mar 2006 11:06:29 +0000
Subject: Re: Extending PEAR::DB (static constructor issue?)
References: 1 2 3 4  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-23260@lists.php.net to get a copy of this message
Forgot to tell you would also have to map all public properties of DB_Common and drivers: bertrand Gugger wrote:
<snip> ******************* *myDB/common.php* ******************* require_once 'DB/common.php'; class myDB_common extends DB_common { var $mydb; // eventually extra properties .... function myDB_common(&$mydb, $extraOptions) {
       $this->DB_Common();
       $this->mydb = & $mydb;
       // map public properties
       $this->fetchmode = &this->mydb->fetchmode;
....
      // from drivers too
      $this->phptype = & this->mydb->phptype;
.... perhaps something like
       foreach(array_keys(get_object_vars($this->mydb) as $prop) {
         $this->$prop = & $this->mydb->$prop;
      }
could do the trick.
      doWhatYouWantExtra($extraOptions);
} // then for *all* standards methods xxxxxx() of DB_Common // and perhaps for some driver specific ones function xxxxxx($param...) // reproduce the exact signature of xxxxxx() {
       // eventually some extra specific to your extension but at least:
       // take care of eventual return by adress
       return $this->mydb->xxxxxx($param...);
} .... // then have your own methods function myMethod($param...) {
       // do what you want around $this->mydb
} .... } That looks quite heavy, but I believe that once realized, this model could support without any problem some upgrades of pear's DB. Regards


« previous php.pear.general (#23260) next »