Le jeu 13/11/2003 à 20:08, Perrin Harkins a écrit :
> On Thu, 2003-11-13 at 10:32, Christophe Musielak wrote:
> > My question is : is it safe to use transactions of multiple objects,
> > doing a commit or rollback at the end as i'm sure i will stay in the
> > same interpreter space and that no other user can ask for the same
> > database handle to do some stuff while i'm working?
> 
> Yes.  Database handles are not shared between interpreters.

Ok
> 
> > btw, ApacheDBI is always returning me a handle with the default
> > parameters i used when issuing the connection ( {AutoCommit => 1} for
> > example), even if i changed the parameters with
> > local->{dbh}->{AutoCommit} = 0.
> 
> Hmmm... Was I talking to you about this on Perlmonks?

Yes

> 
> It sounds like maybe you don't understand what local() does, which is
> not surprising since hardly anyone does.  Any change you make with
> local() only lasts for the current scope.  If you change things without
> local(), it will change the cached handle permanently.

Thanks for your answer Perrin. I tried without local() too and i see
exactly the same result, ie each time i ask DBI via ApacheDBI for a
database handle, i get the handle with the same parameters i created the
handle with, not the ones i just modified, although i can see while
login it's the same handle.

To be clear, as my english not so good :

-----------------------------

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

print "$db"."\n";

print "".$db->{AutoCommit}."\n";

$db->{AutoCommit} = 0;

print "".$db->{AutoCommit}."\n";

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

print "$db"."\n";
print "".$db->{AutoCommit}."\n";

-----------------------------

And here is the result :

Database::Dbh = Apache::DBI::db=HASH(0x8f95d28)
Database::Dbh =1
Database::Dbh =  # ok AutoCommit Off
Database::Dbh = Apache::DBI::db=HASH(0x8f95d28) # ok same handler
Database::Dbh =1 <<<<<<< AutoCommit back On !!


Is this a normal behave of Apache::DBI or am i missing something?

Thanks a lot for your help.

Christophe.



> - Perrin


--
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html

Reply via email to