Re: perl DBI OO



"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
.



Relevant Pages

  • Re: perl DBI OO
    ... know I am making a connection to the DB each time I call getResults ... or am I only using the first connection I make. ... cleaner code-wise. ... At least that way you will get the right error messages. ...
    (comp.lang.perl.misc)
  • HTTPConnection - verbose error messages
    ... unfriendly HTTP error messages) when there is an internal server error ... connection and captures the response messages. ... connection string that inserts to the data base. ... Web server output to application connection when String user = "" ...
    (comp.lang.java.programmer)
  • HTTPConnection - verbose error messages
    ... connection and captures the response messages. ... string that inserts to the data base. ... way to recover verbose detailed error messages in the java application? ... Web server output to application connection when String user = "" ...
    (comp.lang.java.programmer)
  • Re: OE 6 , Takes ages to connect.
    ... How to troubleshoot error messages that you receive when try to send and ... receive e-mail in Outlook and in Outlook Express ... Error message when you use an ICS connection in Outlook: ... with the LAN admin ...
    (microsoft.public.windows.inetexplorer.ie6_outlookexpress)
  • Re: Unable to connect to Internet.
    ... Some firewalls can prevent connection. ... Replies are posted only to the newsgroup for the benefit or other readers. ... >> your internet connection. ... >> please post back to this thread with the details and any error messages. ...
    (microsoft.public.windows.inetexplorer.ie6.browser)