simple object assocition

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I need to share 1 object e.g. "UserPermission" to 2 others e.g.
"Document", "File" objects.
How can I make it without pointers? Many thanks for any help.

Re: simple object assocition

Radim B wrote:
Quoted text here. Click to load it

What do you mean with pointers? One way to go would be to extend the
UserPermission object with other objects.


Re: simple object assocition


On 16 Jul 2004 14:03:06 -0700, (Radim B) wrote:

Quoted text here. Click to load it

I nearly always use a mediator:

class mediator{

    function &obj_instance(){
      static $instance;
      if (!isset($instance)){
        $instance = new obj();
      return $instance;

You can access this in any (class) function with

$obj =& mediator::obj_instance();

In this version all $obj would use the same object, but you can
control that from within the mediator.

HTH, Jochen

Jochen Daum - Cabletalk Group Ltd.
PHP DB Edit Toolkit -- PHP scripts for building
database editing interfaces. /

Site Timeline