Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:16202 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 56145 invoked by uid 1010); 10 May 2005 15:33:33 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 33205 invoked from network); 10 May 2005 15:17:28 -0000 Received: from unknown (HELO suserver.com) (127.0.0.1) by localhost with SMTP; 10 May 2005 15:17:28 -0000 X-Host-Fingerprint: 200.32.3.79 200-32-3-79.prima.net.ar Linux 2.4/2.6 Received: from ([200.32.3.79:43652] helo=mail.bpservers.com.ar) by pb1.pair.com (ecelerity 1.2 r(5656M)) with SMTP id C2/25-35155-580D0824 for ; Tue, 10 May 2005 11:17:28 -0400 Received: (qmail 12062 invoked by uid 0); 10 May 2005 15:17:20 -0000 Received: from unknown (HELO ?192.168.0.240?) (200.42.80.195) by 200-32-3-79.prima.net.ar with SMTP; 10 May 2005 15:17:20 -0000 Reply-To: lpedretti@suserver.com Organization: Axon Sistemas To: Lukas Smith Date: Tue, 10 May 2005 12:16:14 -0300 User-Agent: KMail/1.7.2 References: <200505091130.56300.lpedretti@suserver.com> <200505101148.56888.lpedretti@suserver.com> <4280CBE1.1040801@php.net> In-Reply-To: <4280CBE1.1040801@php.net> Cc: internals@lists.php.net MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-ID: <200505101216.14878.lpedretti@suserver.com> Subject: Re: [PHP] Re: [PHP-DEV] make new return a reference to existent object From: lpedretti@suserver.com (Leonardo Pedretti) How do i obtain the object again having just the key when i want to return = it=20 in another call, if i don't have a reference somewhere? The point would be: object asked id #1, it is not already loaded, load it a= nd=20 return it, end. Then, in another call: object asked id #1, it is already=20 loaded, return the same instance already in memory, end. And outside of thi= s=20 function, if all references of that object are deleted, then the object is= =20 unloaded from memory and so destructed. The behavior i want to reach is that if an instance of some specific class = has=20 the same $id that another instance, then they are the same instance. It's for a database persistent object framework. Everyone that tries to program such a framework gets to the same problem. Regards Leo On Tuesday 10 May 2005 11:57, you wrote: > Leonardo Pedretti wrote: > > Yes, the question was pointed in another way, the destructors are not > > called until the last reference to an object has been removed, but if y= ou > > store a reference in an array so you lately return a reference to the > > already loaded instance instead of creating an aliasing of that instanc= e, > > then you get the undesirable behavior that the object is never destroyed > > until the script ends, because there is always a reference in that array > > and you can not check when references are removed in any way. > > And leaving the array growing while each object that exists in a huge > > database is slowly loaded and never unloaded, is not an option. > > then dont store a reference to the object but instead just store the key > in the array. > > regards, > Lukas =2D-=20 Leonardo Pedretti Axon Sistemas L=EDder de Equipo Proyecto Basalto