On Mar 22, 2005, at 4:46 PM, David Wheeler wrote:
Anyway, it's in now, with support for callbacks on *every* method and *every* handle. So this does what you'd expect:
$dbh->{Callbacks}->{ping} => sub { print "Called ping!\n"; return; };
$dbh->ping;
Nice.
And they work! :-)
======================================================================== #!/usr/bin/perl -w use warnings; use strict; use DBI;
my @args = ( 'dbi:Pg:dbname=testing', 'postgres', 'postgres', { RaiseError => 1, Callbacks => { 'connect_cached.reused' => sub { %{$_[-1]} = (); return; }, } } );
my $dbh = DBI->connect_cached(@args); $dbh->begin_work; print "Pg $dbh: $dbh->{AutoCommit}\n"; $dbh = DBI->connect_cached(@args); print "Pg $dbh: $dbh->{AutoCommit}\n"; __END__ ======================================================================== With the callback, I get:
Pg DBI::db=HASH(0x832d60): Pg DBI::db=HASH(0x832d60):
Instead of
Pg DBI::db=HASH(0x832d60): Pg DBI::db=HASH(0x832d60): 1
This makes me happy. Thanks, Tim!
Regards,
David