in reply to mod_perl ApacheDBI

It sounds like you've understood it correctly: Apache::DBI will give you the same object back if you call connect with the same params, and setting AutoCommit on that object will set it for everyone, until you change it back.

I suspect the problem has to do with inconsistent calls to connect. How does your $thread->Update method get its $dbh? Is it different from what you did before? If you turn on Apache::DBI debugging do you see it making new connections in your subs?

Replies are listed 'Best First'.
Re: Re: mod_perl ApacheDBI
by lergot (Novice) on Nov 13, 2003 at 07:43 UTC
    Thanks for your answer. When i look at the error_log after enabling $Apache::DBI::DEBUG, i see that Apache DBI is always giving me the same handler with the default parameters parameters from my DBI Connect :

    I use a Database object to encapsulate the call to DBI. Here is the constructor :

    sub new {
    my $pkg = shift;

    my $user = $ENV{DB_USER} ;
    my $password = $ENV{DB_PASSWORD} ;
    my $dsn = $ENV{DB_DSN} ;
    my $dbh = DBI->connect($dsn,$user, $password, { AutoCommit => 1, RaiseError => 1 } )||
    die "ERROR NO_CONNECTION_TO_POSTMASTER\n";

    my $obj = {_dbh => $dbh};

    bless $obj, $pkg;

    return $obj;

    }

    And all my other objects calls this contructor with :

    my $db = new Database();

    Then when i need to change autocommit parameters, i do a simple $db->{_dbh}->{AutoCommit} = 0;

    What i can see is that i can't modify the database handlers pool from Apache::DBI, all i can do is modify my local copy.

    Next time one of my object ask for the same DBI handler, i get the original with AutoCommit == 1;

    Christophe