Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:41341 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 87381 invoked from network); 23 Oct 2008 11:22:47 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Oct 2008 11:22:47 -0000 X-Host-Fingerprint: 195.11.217.66 unknown Received: from [195.11.217.66] ([195.11.217.66:28711] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id BF/E8-44135-78E50094 for ; Thu, 23 Oct 2008 07:22:47 -0400 Message-ID: To: internals@lists.php.net Date: Thu, 23 Oct 2008 12:22:45 +0100 Reply-To: nathan@kraya.co.uk Organization: Kraya - Web Development in Edinburgh User-Agent: Thunderbird 2.0.0.17 (Windows/20080914) MIME-Version: 1.0 References: <48FED6DA.2090400@naenius.com> <200810222123.58206.larry@garfieldtech.com> <49005CB9.1070500@ead.fiocruz.br> In-Reply-To: <49005CB9.1070500@ead.fiocruz.br> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Posted-By: 195.11.217.66 Subject: Re: [PHP-DEV] Destructor Order From: nathan@kraya.co.uk (Nathan Rixham) Diogo Galvão wrote: > "The destructor method will be called as soon as all references to a > particular object are removed or when the object is explicitly destroyed > 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 cache >> that object in a static variable somewhere for performance. You're >> also using PDO, so your database connection is a global or singleton >> instance of the PDO class. >> Then your script reaches the end. Does your object get destroyed and >> therefore saved to the 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 deal >> with that issue necessarily, but I think that's the sort of use case >> it's intended to address. >> > just to add it in; in ejb3 in java you have PostConstruct and PreDestroy which are pretty useful; maybe something along the same lines could be implemented in PHP? regards! -- nathan ( nathan@kraya.co.uk ) { Senior Web Developer php + java + flex + xmpp + xml + ecmascript web development edinburgh | http://kraya.co.uk/ }