#!/usr/bin/perl
use DBI;
# create database connection
my $dbh = DBI->connect("DBI:mysql:database=mysql;
host=localhost", "root", "", {'RaiseError' => 1});
# prepare template query
my $sth = $dbh->prepare
("INSERT INTO users (fname, lname) VALUES (?, ?)");
# execute query with first set of parameters
$sth->execute('John', 'Doe');
# execute query with second set of parameters
$sth->execute('Jane', 'Low');
# close connection
$dbh->disconnect();
阅读(392) | 评论(0) | 转发(0) |