You are here: objects destroyed in same order as created? « PHP « IT news, forums, messages
objects destroyed in same order as created?

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация