#! /usr/bin/perl -w
use strict;
use DBI;
my $Db="test";
my $DbHost="192.168.83.137";
my $DbPort=3306;
my $DbUser="root";
my $DbPwd='123456';
my $DbH=DBI->connect("dbi:mysql:database=$Db; host=$DbHost;port=$DbPort",$DbUser,$DbPwd,{PrintError=>0, RaiseError=>0,AutoCommit=>0}) or die "connect to db failed...\n";
my $StrSql='select uin, nickName from info where uin = ?';
my $Sth=$DbH->prepare($StrSql);
my $i = 0;
my $Result;
my $uin;
my $nickName;
my @a = qw( 1 2 3 4 );
foreach $i ( qw(1 2 3 4) ){
$Sth->bind_param(1, $i);
$Result=$Sth->execute();
# $Result=$Sth->execute($i);
die "undefined" if (!defined $Result);
$Sth->bind_columns(undef, \$uin, \$nickName);
# while(($uin,$nickName )=$Sth->fetchrow_array){
while($Sth->fetch()){
print "$uin, $nickName\n";
}
}
$Sth->finish;
$DbH->disconnect;
|