+ -
当前位置:首页 → 问答吧 → 数据库UPDATE表记录,执行无效,版主帮忙看看问题,谢谢

数据库UPDATE表记录,执行无效,版主帮忙看看问题,谢谢

时间:2010-07-31

来源:互联网

#!/usr/bin/perl -w

use strict;
use DBI;

my $DBI;
my $dbh = DBI -> connect('dbi:mysql:test',
                                                'root',
                                                '111111',
                                                {
                                                RaiseError => 1,
                                                AutoCommit => 0
                                                }
                                                ) || die "Database connect not made: $DBI:errorstr \n";


my @valuess = (200);

my $str = qq{ update test set age=21 where age=?};
my $sth = $dbh ->prepare($str);

for (@valuess){
        eval{
        $sth -> bind_param(1,$_->[0]);
        $sth -> execute;
        }
        }
       

$sth -> execute;
$dbh ->commit;
$dbh ->disconnect();

作者: whitecell   发布时间: 2010-07-31

解决了~!

        $sth -> bind_param(1,$_);

作者: whitecell   发布时间: 2010-07-31