zoukankan      html  css  js  c++  java
  • mysql utf8 中文

    #!/usr/bin/perl    
    use DBI;    
    use Encode;
    $user="root";    
    $passwd="1234567";    
    $dbh="192.168.32.232";
    my $table=<STDIN>;  
    chomp  $table;
    print "$table is $table
    ";
    
    my $table=encode("utf8",decode("gbk","$table"));
    print "$table is $table
    ";
    $dbh = DBI->connect("dbi:mysql:database=zjzc;host=192.168.32.232;port=3306",$user,$passwd) or die "can't connect to  database ". DBI-errstr;    
    $dbh->do("SET NAMES utf8");  
    ##my $hostSql = qq{select script  from publish_info where env='$env' and info='$app' and ip='$ip'}; 
    my $sql=qq{select sn,name,productType from  zjzc.Product  where name like '%$table%'};
    print "$sql is $sql
    ";
    $sth=$dbh->prepare($sql);    
    $sth->execute;    
    while (@recs=$sth->fetchrow_array) {    
    foreach (@recs)    
           {print encode("gbk",decode("utf8","$_"))}    
           print "
    ";    
           }   
    	 $dbh->disconnect;     
             

  • 相关阅读:
    八月二十九学习报告
    文本操作
    EL表达式
    注解开发
    逆向
    内置对象和方法
    每日日报2020.11.10 1905
    每日日报2020.11.12 1905
    每日日报2020.11.17 1905
    每日日报2020.11.20 1905
  • 原文地址:https://www.cnblogs.com/zhaoyangjian724/p/6199359.html
Copyright © 2011-2022 走看看