未命名  

use DBI;
#definition of variables
$db="test";
$host="localhost";
$user="root";
$password="root";

my $dbh = DBI->connect ("DBI:mysql:database=$db:host=$host",
$user,
$password)
or die "Can't connect to database: $DBI::errstr\n";


my $sth = $dbh->prepare( "
SELECT *
FROM category");

#execute the query
$sth->execute( );

print "\tQuery results:\n================================================\n";

while ( my @row = $sth->fetchrow_array( ) ) {
print "@row\n";
}
warn "Problem in retrieving results", $sth->errstr( ), "\n"
if $sth->err( );

exit;

 

創作者介紹
創作者 shadow 的頭像
shadow

資訊園

shadow 發表在 痞客邦 留言(0) 人氣()