Nathan Rixham wrote:
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?
Or perhaps you should just stick with Java?
--Jani
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php