|

楼主 |
发表于 2003-12-6 23:35:49
|
显示全部楼层
(12) DBI, connect(), prepare(), execute(), fetchrow_array()[php]
#!/usr/bin/perl
use strict;
use DBI;
my $dbh = DBI->connect("dbi:mysql:dbname", 'user','passwd', '')
or die "can't connect!\n";
my $sql = qq/show variables/;
my $sth = $dbh->prepare($sql);
$sth->execute();
while(my @array=$sth->fetchrow_array())
{
printf("%-35s", $_) foreach(@array);
print "\n";
}
$dbh -> disconnect();
exit 0;[/php] |
|