<?php class BaseDB { var $oDB; function BaseDB { $DSN="mysql://root:haslo@localhost:3306/newslater"; $oDB=new DB(); $oDB=$oDB->connect($DSN); if (PEAR::isError($oDB)) { $this->$oDB=null; return null; } } } ?>
<?php class NewslaterConfig { var $mailPerHoure; var $fromName; var $fromEmail; var $charset; var $type; function NewslaterConfig($mPH=null, $fN=null, $fE=null, $ch=null, $type=null) { $this->mailPerHoure=$mPH; $this->fromName=$fN; $this->fromEmail=$fE; $this->charset=$ch; $this->type=$type; } } class NewslaterConfigDAO extends BaseDB { $sQ=" SELECT * FROM newslater_config "; $aRes = $this->oDB->getAssoc($sQ); if (PEAR::isError($aRes)) { #print $aRes->getMessage(); return NULL; } return $this->doReturnFromAssArray($aRes); } $sQ=" UPDATE newslater_config SET `!`=? "; $stmt=$this->oDB->prepare($sQ); ); $this->oDB->execute($stmt, $aData); return } return new NewslaterConfig($aRes['mainperhoure'],$aRes['fromname'],$aRes['fromemail'],$aRes['charset'],$aRes['type']) } } ?>
chodzi o to, ze tak to nie dziala. nie moge odwołać się poprzez $this w statycznej metodzie.
chcialbym zrobic klase w ktorej beda metody fabrykujace ktore beda korzystac z obiektu DB.