<pre name="code" class="python">jrhdpt02:/root/sbin# cat t1.pl
#!/usr/bin/perl
use DBI;
$user="root";
$passwd="xxxxx";
$dbh="";
$dbh = DBI->connect("dbi:mysql:database=zjzc;host=127.0.0.1;port=3306",$user,$passwd) or die "can't connect to database ". DBI-errstr;
#$dbh->do("SET NAMES utf8");
$sth=$dbh->prepare("select sn,duration,name,maxUnit,addUnit,productType from zjzc.Product where sn in (263,121,122);");
$sth->execute;
while (@recs=$sth->fetchrow_array) {
foreach (@recs)
{print "$_"}
print "
";
}
$dbh->disconnect;
jrhdpt02:/root/sbin# perl t1.pl
12123??-??30?250000011
12222????-????5170000100003
263180????-????2000000100003
jrhdpt02:/root/sbin# cat t1.pl
#!/usr/bin/perl
use DBI;
$user="root";
$passwd="R00t,uHagt.0511";
$dbh="";
$dbh = DBI->connect("dbi:mysql:database=zjzc;host=127.0.0.1;port=3306",$user,$passwd) or die "can't connect to database ". DBI-errstr;
$dbh->do("SET NAMES utf8");
$sth=$dbh->prepare("select sn,duration,name,maxUnit,addUnit,productType from zjzc.Product where sn in (263,121,122);");
$sth->execute;
while (@recs=$sth->fetchrow_array) {
foreach (@recs)
{print "$_"}
print "
";
}
$dbh->disconnect;
jrhdpt02:/root/sbin# perl t1.pl
12123中均-至信30号250000011
12222中均尊享-贰拾壹号5170000100003
263180中均尊享-玖拾伍号2000000100003