Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:1413 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 2702 invoked from network); 10 May 2003 04:01:02 -0000 Received: from unknown (HELO vckyb1.nw.wakwak.com) (211.9.230.144) by pb1.pair.com with SMTP; 10 May 2003 04:01:02 -0000 Received: from at.wakwak.com (at.wakwak.com [211.9.230.135:25]) by vckyb1.nw.wakwak.com (Postfix) with ESMTP id EF8443FE2B; Sat, 10 May 2003 13:01:00 +0900 (JST) Received: from at.wakwak.com (z223.211-19-94.ppp.wakwak.ne.jp [211.19.94.223]) by at.wakwak.com (8.12.9/8.12.9/2003-03-31) with SMTP id h4A410H5029890; Sat, 10 May 2003 13:01:00 +0900 (JST) (envelope-from moriyoshi@at.wakwak.com) Date: Sat, 10 May 2003 13:03:57 +0900 X-Mailer: EdMax Ver2.85.3F MIME-Version: 1.0 To: "Paul Lunceford" Cc: internals@lists.php.net Message-ID: <20030510130357OKbKot@at.wakwak.com> Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit In-Reply-To: <20030509150204.20095.qmail@pb1.pair.com> References: <20030509150204.20095.qmail@pb1.pair.com> Subject: Re: [PHP-DEV] PHP Objects and cyclical references - HELP From: moriyoshi@at.wakwak.com (Moriyoshi Koizumi) Hi, This list is intended for the development of php runtime, not for such user questions. Please ask your questions at php-general@lists.php.net. Thanks. Moriyoshi hint: use "&" "Paul Lunceford" wrote: > I am just getting to know PHP and am a big proponent of object structures. > I am trying to use PHP classes that get instanciated on the fly from data > within MySQL. My problem is this. If I have a Department class that has as > a variable Employees and an Employee class (along with an Employees class > with a list variable for getting sets of employees) that has a variable > Division (to navigate back and forth). I seem to have problems getting the > objects to point to one another. PHP does not seem to like cyclical > references and makes copies of my objects. So if I have the following > function in my Division class: > > function getEmployees() > { > $myEmployees = new Employees($this->DivisionID); > forEach ($myEmployees->list as $employee) > { > $employee->Division = $this; > $this->Employees[$employee->EmployeeNumber] = $employee; > } > } > > the reference of $employee->Division becomes only a copy of the $this > object. This is a problem because the first employee to go through the loop > when asked other employees within his division sees none, thinking himself > the only employee of the division. Does anyone know the solution? Please > email response to paul.luceford@enterworks.com. Thanks.