一、標准操作
1、連接、關閉
my $dbh = DBI->connect(”DBI:MySQL:database=DBname;host=localhost”,”user”,”pwd”, {’RaiseError’ => 1});
… …
$dbh->disconnect();
2、類似插入等無返回操作
my $sqr = $dbh->prepare(”insert into table_name(Name,region_id,inuse,url) values (’”.$r_name.”‘,’”.($t+1).”‘,’1′,’”.$r_url.”‘) “);
$sqr->execute();
3、取得自增長的ID
執行插入操作後
my $table_key = $dbh->{’MySQL_insertid’};
4、Select操作
my $row;
while ($row = $sqr->fetchrow_arrayref) {
printf $row->[0].”++”.$row->[1].”\n”;
}