Reply to Re: __destruct() destroy an object that contains a reference to another object

Your name:

Reply:


Posted by Mortimer on 07/19/07 08:00

Iván Sánchez Ortega ha pensato forte :
> Mortimer wrote:
>
>> I have two objects and the second one is using an instance of the
>> first.
>> As displayed in the example below, the Garbage Collector calls the
>> destruct method of the first class before the second even if the second
>> contains a reference to the other, so i can't complete all the
>> operations not having all "the code available"!
>
> If it's totally and absolutely neccesary for you to keep an order on
> destroying objects, unset() them when neccesary.
>
> Now, a question for you: Imagine we have two objects, each with a reference
> to the other one (i.e. a circular dependency). Which one should the GC
> destroy first??

Ok thanks, understood..
The fact is that the first object is a Mysql DB Handler and the second
is a DB Session Handler.

In the DB Session the parameter initially was the link to Db obtained
from the Db handler. The destruct method of the Db handler close the
connection so i lost the Db link and the possibility of writing the
session on the Db. I wanted to avoid to open 2 connections.

I "solved" the problem by not closing conection to the Db in the
destruct method but leaving this role to the end of the script (with no
persistent connections).

[Back to original 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

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