Perl-Sensitive Sunglasses | |
PerlMonks |
Re: DBI selectall_arrayrefby davido (Cardinal) |
on Sep 02, 2004 at 16:12 UTC ( [id://387969]=note: print w/replies, xml ) | Need Help?? |
In addition to the comments regarding quoting of field names, I wanted to mention one other thing. Just as you wouldn't dream of opening a file without checking the return value of open to see that the open was successful, you shouldn't just assume that your database operations are successful either, without proper error checking. For example, when you connect to the database:
Likewise, you need to error check after executing your selectall_arrayref(). This is explained in the POD:
Also, maybe I'm not getting it, but when you call the connect() method, according to the DBI docs, the install_driver() method is called implicitly if needed. I don't think there's any need to call it yourself, and in fact, if you do call it yourself, calling it after attempting to connect is too late; you would need that driver to be installed before you can connect. I haven't run into any need to use the install_driver() method, so I could be way off, but it seems wrong to be installing the driver after trying to connect to the database. Dave
In Section
Seekers of Perl Wisdom
|
|