Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re: lost in my first Perl module

by ikegami (Patriarch)
on Jun 22, 2010 at 19:53 UTC ( #845957=note: print w/replies, xml ) Need Help??

in reply to lost in my first Perl module

Looking at your wish list, you're not abstracting anything away at all. You're just adding a needless layer.

open a DBI connection given a hostname, database, username and password;


the user (if in an interactive context) for any of the four things above if missing;

Bad idea. Data storage and user interaction are unrelated tasks.

supply a method for preparing a query;


supply a method for executing a prepared query;


allow the user to just call DBModule::run_query("select ... from ... where ...") and expect the module to properly prepare/execute

If $dbh->prepare + $sth->execute is really a hardship,

sub do_select { my($dbh, $statement, $attr, @bind_values) = @_; my $sth = $dbh->prepare($statement, $attr) or return undef; $sth->execute(@bind_values) or return undef; return $sth; }

while helpfully handling / trapping Sybase error codes

RaiseError => 1

supply a method to reformat the result set into various hashes/arrays


supply a method to release a result set (equiv to $sth->finish()

$sth->finish, though rarely needed.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://845957]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (2)
As of 2022-09-30 00:38 GMT
Find Nodes?
    Voting Booth?
    I prefer my indexes to start at:

    Results (125 votes). Check out past polls.