Re: app design issue

From: Date: Sat, 16 Aug 2003 03:54:26 +0000
Subject: Re: app design issue
References: 1  Groups: php.pear.general php.pear.general 
Request: Send a blank email to pear-general+get-7235@lists.php.net to get a copy of this message
the current trick to fake static variables is usually use semi-private globals.. as below using _CLASS_NAME to associate them with the classes using singleton method calls is expensive if you have to fetch the object alot on a page.. Regards Alan Robin Ericsson wrote:
I have this setup: class A constructor()
    b = new Class B     b->run();
$GLOBALS['_CLASS_B']['db'] = null;
class B run()
global $_CLASS_B;
    db = new PEAR::DB
$_CLASS_B['db'] = new PEAR::DB
$db = &$_CLASS_B['db']
    do db stuff
    if (specialoccasion)
      c = new Plugin
      c->run()
  class C
Does everybody understand this? My problem is that class also needs to use the db object in class C. I could pass the db object on the class C as I do it today, but it doesn't look nice to do it. Should it place as a global object? Singleton? best regards Robin


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