I have a question in follow up of threads 119171 and 103323. I have exactly the same problem as I store my dbi object as an attribute of my object. For example.
Now I want to commit the transactions in a DESTROYsub opendb { my $self=shift; $self->{_dbh}=DBI->connect(...); return $self->{_dbh}; }
The strange thing is that warn is not called in every script script, although I am sure that I call opendb everytime. I think that the _dbh attribute is destroyed before $self itself is destroyed!sub DESTROY { my $self=shift; local($@); if ( $self->{_dbh} and $self->{_dbh}->ping ) { warn; ## to debug $self->{_dbh}->commit; $self->{_dbh}->disconnect; } }
This problem is noted before, and a forced $self->{_dbh}->commit is the best solution. But they mention also that this problem will be solved in future versions of perl.
Now, is this already solved? I use 5.005_03 on solaris (which is not installed nor maintained by me).
And is there a good way of debugging OO problems like this?
(using some Devel package?)
Thanks for your assistance,
---------------------------
Dr. Mark Ceulemans
Senior Consultant
IT Masters, Belgium
In reply to DESTROY and DBI by mce
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |