|
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).
Navigation:
[Reply to this message]
|