代码如下表已经建立好-----------------------------------------------------------------------------#!/usr/bin/perluseDBI;my$dbh=DBI->connect("DBI:mysql:database=test;host=1...
代码如下 表已经建立好
-----------------------------------------------------------------------------
#! /usr/bin/perl
use DBI;
my $dbh = DBI->connect("DBI:mysql:database=test;host=127.0.0.1","root","1111",{'RaiseError' => 1});
$dbh->do("SET NAMES utf8");
$dbh->do('INSERT INTO foo VALUES (1, ' . $dbh->quote('Tim') . ')');
my $sth = $dbh->prepare("SELECT * FROM test LIMIT 0,1000");
$sth->execute;
while (my $ref = $sth->fetchrow_hashref()){
print "Found a row: id = $ref->{'id'},name = $ref->{'name'}\n";
}
$sth->finish();
$dbh->disconnect();
---------------------------------------------------------------------------------
一直运行不成功 报错如下
---------------------------------------------------------------------------------
Unrecognized character \xEF in column 67 at perl/dbi_test.pl line 8.
展开