Wednesday, July 24, 2002, 5:04:06 AM, you wrote:
MD> I just wrote this message in the wrong list so i'll be short...

MD> I have two classes:
MD>  - mysql_connection
MD>  - data_collection

MD> data_collection REQUIRES a mysql_connection object to work. So i decided to
MD> pass this object in the constructor for the  data_collection, but when i do
MD> so it seems it creates a copy of this object and doesn't use the object i
MD> had previously created...

MD> I tried to do function data_collection(&$mysql_server){
MD>     ...
MD> }

MD> But even the & sign like they say to use on the php.net web site doesn't
MD> work, it creates a copy of the object. The only way i found to bypass this
MD> problem is to do:

my_collection->>mysql_server = &$mysql_server;

MD> which will assign a reference of the mysql_collection object to my
MD> collection, but this means i need to modify something like 45 files of my
MD> web site and also i have to add some init settings because they where done
MD> in the constructor where you needed the connection...

MD> please help me out!!!

MD> InsaneCoder

what I do is to create a global array of class objects to provide
inter class communication.

class a {
  var $test;
  function a(){
          global $class;
          $class['a'] =& $this;
          $this->test = 'Opened';
class b {
 function b(){
  global $class;
  echo 'Class a value = '.$class['a']->test.'<br>';

$a = new a();
$b = new b();

Best regards,

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to