http://www.perlmonks.org?node_id=1016619

rodbass63 has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I want to start learning Class::DBI and put the default DBI aside for a while. I created this method that does a simple select, I want to learn how to do it the Class::DBI way. Here's my method doing it the old fashion way.
sub test { # DATA SOURCE NAME my $dsn = "dbi:mysql:$dbname:localhost:3306"; # PERL DBI CONNECT my $connect = DBI->connect($dsn, $user, $pw); my $query = "SELECT username, password, created FROM TempAccountRegist +ry"; my $query_handle = $connect->prepare($query); # EXECUTE THE QUERY $query_handle->execute(); # BIND TABLE COLUMNS TO VARIABLES $query_handle->bind_columns(\$username, \$password, \$created); # LOOP THROUGH RESULTS while($query_handle->fetch()) { print DB "$username, $password, $created\n"; } }
I have another file with Class::DBI
use base 'Class::DBI'; DataStore::DAO::Base->connection("dbi:$source:$dbname", $user, $passwo +rd); # I would like to add the method doing it the Class::DbI # way here.
Where I work, they strive on Class:DBI, so I'm eager to learn it. Thanks for your help. usaims