Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:41342 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 99272 invoked from network); 23 Oct 2008 11:54:07 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Oct 2008 11:54:07 -0000 Authentication-Results: pb1.pair.com header.from=jani.taskinen@sci.fi; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=jani.taskinen@sci.fi; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain sci.fi from 63.208.196.178 cause and error) X-PHP-List-Original-Sender: jani.taskinen@sci.fi X-Host-Fingerprint: 63.208.196.178 mho-01-bos.mailhop.org Received: from [63.208.196.178] ([63.208.196.178:56184] helo=mho-01-bos.mailhop.org) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 36/7B-44135-ED560094 for ; Thu, 23 Oct 2008 07:54:06 -0400 Received: from a88-112-30-186.elisa-laajakaista.fi ([88.112.30.186] helo=localhost.localdomain) by mho-01-bos.mailhop.org with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.68) (envelope-from ) id 1KsylP-000L3Z-Ds; Thu, 23 Oct 2008 11:54:03 +0000 X-Mail-Handler: MailHop Outbound by DynDNS X-Originating-IP: 88.112.30.186 X-Report-Abuse-To: abuse@dyndns.com (see http://www.mailhop.org/outbound/abuse.html for abuse reporting information) X-MHO-User: U2FsdGVkX18XISGcI1VM2uqw57YbCqoFzW96lLUp3Xw= Message-ID: <490065D8.8020109@sci.fi> Date: Thu, 23 Oct 2008 14:54:00 +0300 Reply-To: jani.taskinen@iki.fi User-Agent: Thunderbird 2.0.0.16 (X11/20080723) MIME-Version: 1.0 To: nathan@kraya.co.uk CC: internals@lists.php.net References: <48FED6DA.2090400@naenius.com> <200810222123.58206.larry@garfieldtech.com> <49005CB9.1070500@ead.fiocruz.br> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Destructor Order From: jani.taskinen@sci.fi (Jani Taskinen) Nathan Rixham wrote: > Diogo Galv=C3=A3o wrote: >> "The destructor method will be called as soon as all references to a >> particular object are removed or when the object is explicitly destroy= ed >> or in any order in shutdown sequence." >> >> As far as I understand it if your active record references the PDO >> instance (say $this->conn) your object gets destroyed before the >> connection object. >> >> Perhaps it's a better approach then introducing destruction order for = >> global or singleton problems. >> >> >> wbr, >> Diogo >> >> Larry Garfield wrote: >>> On Wednesday 22 October 2008 2:31:38 am Mike van Riel wrote: >>> >>> I believe the "end of your script" part is the problem. Imagine you = >>> have some object (say, ActiveRecord style) that writes itself to the = >>> database when it's destroyed if the data has been modified. Now=20 >>> cache that object in a static variable somewhere for performance. =20 >>> You're also using PDO, so your database connection is a global or=20 >>> singleton instance of the PDO class. Then your script reaches the=20 >>> end. Does your object get destroyed and therefore saved to the=20 >>> database before or after the PDO object goes away? I don't actually = >>> know. >>> >>> I'm not saying that manual destructor order is the correct way to=20 >>> deal with that issue necessarily, but I think that's the sort of use = >>> case it's intended to address. >>> >> >=20 > just to add it in; in ejb3 in java you have PostConstruct and PreDestro= y=20 > which are pretty useful; maybe something along the same lines could be = > implemented in PHP? Or perhaps you should just stick with Java? --Jani