#!/usr/bin/perl -T
# FILE:  select_fetchrow_hashref
# Demonstrates retrieving info from a database using fetchrow_hashref 

use DBI;
use strict;
use warnings;

my $db = "shared01";  #database already exists 
my $server = "burks";
my $dbh = DBI->connect("DBI:mysql:$db:$server","tgarrett", "transy1780")
  or die("Error:  $DBI::errstr");
  

my $query1 = qq(select * from product);
my $sth = $dbh->prepare($query1);
$sth->execute;
no warnings;
while (my $record = $sth->fetchrow_hashref)
#grabs and stores in a reference to a hash table 
{
  print "Pid:                $record->{Pid}\n";
  print "Name of Product:    $record->{Item}\n";
  print "Description:        $record->{Descr}\n";
  print "Price:              $record->{Price}\n";
  print "Vid:                $record->{Vid}\n";
}
print "\n";
$dbh->disconnect;


