Re: perl DBI OO
- From: xhoster@xxxxxxxxx
- Date: 13 Aug 2007 19:30:14 GMT
"jtbutler78@xxxxxxxxxxx" <jtbutler78@xxxxxxxxxxx> wrote:
On Aug 13, 1:06 pm, xhos...@xxxxxxxxx wrote:
"jtbutle...@xxxxxxxxxxx" <jtbutle...@xxxxxxxxxxx> wrote:
I have a module that I instantiate a DBI connection from. My
question is - I am doing the right way? It works but I dont know
know I am making a connection to the DB each time I call getResults
or am I only using the first connection I make. I call getResults
inside loops or make several calls to it within my application and
its a waste to make connections with each call.
You are making a new connection each time you call "new", and just
re-use that connection each time you call getResults on a given object
obtained by new. So if your class is only instantiated once per
program, then you only make one connection. But from the bigger
picture, I'd have to wonder what the point is. It looks like you just
made a simple wrapper around DBI which adds no new functionality but
takes away a lot of existing functionality.
I made this because I am making the calls all the time and its much
cleaner code-wise.
It is cleaner than just turning on RaiseError and then
calling $dbi->selectall_arrayref as needed?
At least that way you will get the right error messages. With your code,
you're likely to get can't call method on undef value errors instead of the
correct error message, as you only do error checking at one out of 3
potential DBI-error points.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
.
- Follow-Ups:
- Re: perl DBI OO
- From: jtbutler78@xxxxxxxxxxx
- Re: perl DBI OO
- References:
- perl DBI OO
- From: jtbutler78@xxxxxxxxxxx
- Re: perl DBI OO
- From: jtbutler78@xxxxxxxxxxx
- perl DBI OO
- Prev by Date: Re: how to tranpose a huge text file
- Next by Date: Re: Pagination II
- Previous by thread: Re: perl DBI OO
- Next by thread: Re: perl DBI OO
- Index(es):
Relevant Pages
|