3) 测试:
使用MySQL数据库(使用mSQL也可以)建立一个数据库:abacus,写一个简单的perl程
序:perlmysql.cgi,
从一个数据库abacus中读出所有的表名并且显示。
#!/usr/bin/perl
use DBI;
print "Content-type:
text/html\n\n";
print "\n";
print "\n";
$driver="mysql";
$dbh=DBI->connect("DBI:mysql:abacus:mysql.szabacus.com","root","abcde")||die
"can
not connect database";
$sth=$dbh->prepare("show
tables")||die "occur an error when query database";
$sth->execute();
$numRows=$sth->rows;
while(@row=$sth->fetchrow_array)
{
print "Table:
$row[0]\n";
}
print "query lines=$numRows\n";
$sth->finish();
$dbh->disconnect();
exit;
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/90618/viewspace-663915/
,如需转载,请注明出处,否则将追究法律责任。