From: Benjamin Trott <[EMAIL PROTECTED]>


> > PH> Don't open a connection during startup.
> > PH> Open a connection in the child process instead.
> 
BT > I will second this. I've done this (unintentionally) when using MySQL, and
BT > you get a lot of weird errors about statement handles being active, etc.

I haven't read the entire thread, so forgive me if I'm restating. But there are 
reasons for sharing DB connections (and reasons not to). In the case of MySQL and 
getting messages about active statement handles, that's because you're disconnecting 
the DBH. If you are in a shared connection enviroment with MySQL, you are winning. 
Since you don't have to worry about things like transactions and rolling back somebody 
elses changes. All you need to do is finish() your statement handled when you are 
finished with them:

  $sth->finish;

This will prevent the errors you are seeing and will allow you to keep the shared DB 
connection. A shared connection is usefull for efficiency, since creating a connection 
may be expensive.


From: Rasoul Hajikhani <[EMAIL PROTECTED]>
> I am sorry but this topic is confusing me... Are you saying that
> persistent DB connection objects are bad?

It sounds like that, doesn't it?


> I am about to switch to Apache::DBI for that very reason. I don't
> want to create a new db handle with every request. Should I stop,
> or am I missing something here?

Nope, you've got it. If you don't have transactions (anything else?) to worry about, 
I'd say to use Apache::DBI. Remember, from the Apache::DBI docs:

    Do NOT change anything in your scripts. The usage of this
    module is absolutely transparent !

---
Rodney Broom
Programmer: Desert.Net



Reply via email to