Chinaunix首页 | 论坛 | 博客
  • 博客访问: 438828
  • 博文数量: 116
  • 博客积分: 2756
  • 博客等级: 少校
  • 技术积分: 1163
  • 用 户 组: 普通用户
  • 注册时间: 2008-07-29 21:21
文章分类

全部博文(116)

文章存档

2018年(1)

2017年(1)

2016年(30)

2015年(41)

2014年(23)

2011年(7)

2010年(9)

2008年(4)

分类: Android平台

2016-05-29 09:21:55


注意:要设定编码。

点击(此处)折叠或打开

  1. #! /usr/bin/env perl

  2. use strict;

  3. use warnings;

  4. use DBI;

  5. my $hostname = "xxx";
  6. my $database = "xxx";
  7. my $username = "xxx";
  8. my $userpass = "xxx";

  9. my $dbh = DBI->connect("dbi:mysql:$database:$hostname:3306", $username, $userpass);

  10. $dbh->do("SET character_set_client='utf8'");
  11. $dbh->do("SET character_set_connection='utf8'");
  12. $dbh->do("SET character_set_results='utf8'");

  13. my $sth = $dbh->prepare("select foo_01, foo_02 from foo_table");

  14. $sth->execute();

  15. while (my $row = $sth->fetchrow_hashref())
  16. {
  17.     print $row->{'foo_01'};
  18.     print "\t";
  19.     print $row->{'foo_02'};
  20.     print "\n";
  21. }

阅读(722) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~