Mailinglisten-Archive |
Aloha,
> Von: Steffen Gebert[SMTP:php-list at stg-design.de]
>
> Jetzt habe ich es folgendermaßen:
>
... ist doch schon mal ziemlich elegant ;)
> $Db = new DB;
>
> class Foo
> {
> var $Db;
>
> // constructor
> function Foo ( )
> {
> global $Db;
> this->Db =& $Db;
> }
>
besser wäre
function Foo(&$Db){ # Konstruktor
$this->Db = Db;
}
> function Bar ()
> {
> $this->Db->query( )
> }
> }
> $Foo = new Foo;
>
in normalen Funktionen kannst du ja das DB-Handle mit
übergeben:
function Normal(&$Db, ....) {
.....
}
Grüße,
Mathias
php::bar PHP Wiki - Listenarchive