|
发表于 2009-12-1 21:29:08
|
显示全部楼层
连接到MySQL数据库
my $dsn = "DBI:mysql:database=food_db;host=localhost";
my $username = "username";
my $password = "password";
my $dbh = DBI->connect($dsn, $username, $password);
执行SQL
my $sth = $conn->prepare($sql_all);
$sth->execute(@parameters);
获取数据
while (my $row_data = $sth->fetchrow_hashref()) {
# ...
}
断开连接
DBI的所有API
http://search.cpan.org/~timb/DBI-1.609/DBI.pm |
|