Created
August 20, 2010 12:34
-
-
Save dynax60/540209 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use Mojolicious::Lite; | |
use Mojo::ByteStream 'b'; | |
use Mojo::JSON; | |
use utf8; | |
... | |
our $dbh = DBI->connect("dbi:mysql:dbname=cli;host=localhost", | |
'user', 'pass', | |
{ PrintError => 0, RaiseError => 1 }); | |
$dbh->do("SET NAMES utf8"); | |
$dbh->do("SET CHARACTER SET utf8"); | |
$dbh->do("SET character_set_connection=utf8"); | |
$dbh->do("SET character_set_client=utf8"); | |
$dbh->do("SET character_set_server=utf8"); | |
$dbh->do("SET character_set_results=utf8"); | |
get '/' => sub { | |
... | |
my $rows = $dbh->selectall_arrayref(q{ | |
select title from contract where id = ? | |
}, {}, $id); | |
grep { grep { $_ = b($_)->decode('UTF-8') } @$_ } grep { $_ } @$rows ; | |
$self->render( 'rows' => $rows ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Если обернуть запросик в b("..")->decode('UTF-8') рендерится нормально.