|
Posted by Jasper Bryant-Greene on 07/21/05 07:45
Hi all
I am currently working on a PHP 5 application. For the sake of
simplicity, I'll only describe 3 classes here, as that is all that is
required for you to see my problem.
I have a DB class that interacts with the database, a Session class that
controls the session with the user, and a User class that stores the
information about the logged-in user.
I create instances of these classes in the order [DB, Session, User] at
request startup. They have to be in this order as the Session and User
classes need the database, and the User class needs the session.
The User and Session destructors both need the database to write any
changed information back to the database, but it seems that the
destructors are called in the order that the objects are created, so the
database is taken down first.
Wouldn't it make more sense for just about all applications to destroy
objects in the reverse order that they were created? Is there any way to
work around this?
Jasper
Navigation:
[Reply to this message]
|