Mojo Mysql utf-8字符集 需要{mysql_enable_utf8 => 1}

 get '/api/log_mon/get_log' => sub{
   my $c = shift;
   my $env = $c->param('env');
   my $host = $c->param('host');
   use DBI;
my $dbUser='DEVOPS';  
my $user="root";  
my $passwd="1234567"; 

my @arr2=();;  
my $dbh  = DBI->connect("dbi:mysql:database=DEVOPS;host=192.168.32.161;port=3306",$user,$passwd,{mysql_enable_utf8 => 1} ) or die "can't connect to database ". DBI-errstr;
my $hostSql = qq{select   sn,host_name,host_ip,v_date,info,env from err_info where env='$env' and host_name='$host' order by v_date desc limit 20}; 
my ($a1, $a2, $a3,$a4,$a5,$a6,$a7,$a8,$a9);  
my $selStmt = $dbh->prepare($hostSql);  
$selStmt->execute();  
$selStmt->bind_columns(undef, \$a1, \$a2, \$a3,\$a4,\$a5,\$a6);  
#$selStmt->execute();  
while( $selStmt->fetch() ){ push (@arr2, "$a1  $a2  $a3 $a4 $a5 $a6\n" );
};
chomp @arr2;
print "\@arr2 is @arr2\n";
 $c->render(json =>  \@arr2);
 };
  

转载于:https://www.cnblogs.com/zhaoyangjian724/p/6199845.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值