Hi,
Read the DBI down because for this kind of selects you can use methods of the DBI to take the data back to the data type you want...
For example:
$ary_ref = $dbh->selectall_arrayref($statement); $hash_ref = $dbh->selectall_hashref($statement, $key_field); $ary_ref = $dbh->selectcol_arrayref($statement); $ary_ref = $dbh->selectcol_arrayref($statement, \%attr); @row_ary = $dbh->selectrow_array($statement); $ary_ref = $dbh->selectrow_arrayref($statement); $hash_ref = $dbh->selectrow_hashref($statement);
So I don't think that your approach was worst in time, and the connection stuff is not much work to code it... I wouldn't use something like you post...
You can also use some nifty things like Class::DBI or some more simple but also very confortable like DBIx::Abstract
Normally you use config files where you set all the database connection data so that you only need the line where you connect/create the DBI object... and the keep on rollin'
Regards,
I like merlyn's disclaimer
In reply to Re: easier to get data from a database
by fmerges
in thread easier to get data from a database
by rsiedl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |