Re: Apache::DBI connect

Perrin Harkins <[email protected]>
Newsgroups gmane.comp.apache.mod-perl
Message-ID <CAC0_be3mrZnUe5sOn5VgtzxLgR_os_dP65+J_mN-cfg3up-Tgg@mail.gmail.com>
On Thu, Nov 7, 2013 at 11:06 PM, Xinhuan Zheng <[email protected]>wrote:

> As I turned on more debugging, when the problem occurs, the Apache cached
> connection reference is different than the database handle reference the
> query is using.


Which query are you talking about?  The ping in Apache::DBI?  Or something
else in your own code?


> We use Apache::DBI and DBI and use Apache::DBI is before DBI. We actually
> call DBI->connect_cached and based on DBI document, I guess this would be
> handled by Apache::DBI connect.


Yes, it should be.


> However, I guess we also defined a base class that can store a database
> handle. There are subclasses inherited from this base class. Is that good
> idea to store a database handle in a base class?


No, don't do that.  You should pick one approach for managing database
handles, whether it's Apache::DBI or something else, and only use that.  If
you keep a database handle around in a global somewhere, it may time out
and nothing will ping it because you're not calling connect() on each
request.

- Perrin
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.