- 論壇徽章:
- 0
|
有個(gè)mysql的表t(a,b,c)3列。
現(xiàn)在要取得表t的所有記錄后,遍歷記錄,而且有時(shí)往前有時(shí)往后,同時(shí)更新c列的值,這在perl里要怎么寫(xiě)?
# 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";
}
上面是遍歷表的記錄,并輸出,但不知道要如何更新回?cái)?shù)據(jù)庫(kù)中?
謝謝。 |
|