- 论坛徽章:
- 0
|
有个mysql的表t(a,b,c)3列。
现在要取得表t的所有记录后,遍历记录,而且有时往前有时往后,同时更新c列的值,这在perl里要怎么写?
# Connect to target DB
my $dbh = DBI->connect("DBI:mysql:database=arabpa");
my $sth = $dbh->prepare('SELECT * FROM perl_test') or die $dbh->errstr;
$rv = $sth->execute or die "can't execute the query: $sth->errstr\n";
print "rowscount=$rv\n";
my $table = $sth->fetchall_arrayref or die "$sth->errstr\n";
my($i, $j);
for $i ( 0 .. $#{$table} ) {
for $j ( 0 .. $#{$table->[$i]} ) {
print "$table->[$i][$j]\t";
} print "\n";
}
上面是遍历表的记录,并输出,但不知道要如何更新回数据库中?
谢谢。 |
|