The Perl operation to MySQL.
One, standard operation
1, join, shut
My $dbh = DBI->connect(”DBI:mYsql:dAtabase=DBname;host=localhost” , ”user” , ”pwd” , {’RaiseError’=>1});
……
$dbh->disconnect();
2, similar insert etc without return an operation
My $sqr = $dbh->prepare(”insert Into Table_name(Name, region_id, inuse, url) Values (’” . $r_name. ”‘ , ’” . ($t 1) . ”‘ , ’1′ , ’” . $r_url. ”‘) “);
$sqr->execute();
3, obtain the ID that grows oneself
Carry out after inserting an operation
My $table_key = $dbh->{’mysql_insertid’};
4, Select operation
My $row;While ($row = $sqr->fetchrow_arrayref) {Printf $row->[0] . ” ” . $row->[1] . ”n”;
}
Perl operates the method of Mysql database
来源:
作者:Stand originally
时间:2008-12-21
Tag:
点击:
最新评论共有 0 位网友发表了评论
查看所有评论
发表评论

