Re: [Dancer-users] Using utf-8 data from database and template toolkit
Hi, Does it work for you without DBIx::Class? I did the following: 1. Created a SQLite database: sqlite3 names.sqlite 2. Executed the following SQL sqlite> .read names.sql where names.sql contains: create table names (FirstName varchar(20), LastName varchar(20)); insert into names (FirstName, LastName) values ('Bedřich', 'Smetana'); insert into names (FirstName, LastName) values ('Antonín', 'Dvořák'); insert into names (FirstName, LastName) values ('Fréderyck', 'Chopin'); 3. My mywebapp.pl looks like this (the database names.sqlite is in the folder db under the default mywebapp created by dancer): #!/usr/bin/perl use Dancer; use mywebapp; use Data::Dumper; use Template; use DBI; get '/names/' => sub { my $dbh = DBI->connect("dbi:SQLite:dbname=db/names.sqlite", "", ""); my $sql = "select FirstName, LastName from names"; my $sth = $dbh->prepare($sql); $sth->execute; my $names = $sth->fetchall_arrayref; template 'names' => { 'names' => $names }; }; dance; 4. And my TT2 template looks like this: <table> [% FOREACH n IN names %] <tr> <td>[% n.0 %]</td> <td>[% n.1 %]</td> </tr> [% END %] </table> This setup works for me without any data corruption issues. I am on Mac OS 10.6, with Perl 5.10.0, SQLite3 and Dancer 1.173.
On Tue, Apr 6, 2010 at 1:10 PM, Deepak Gulati <deepak.gulati@gmail.com> wrote:
Hi,
Does it work for you without DBIx::Class?
Hi, I tried it without DBIx::Class and works fine. Then I comment out the line: #__PACKAGE__->utf8_columns(qw/ciudad nombres apellidos comentarios/); in the schema class file and now works fine ;) Thanks! -- Christian Sánchez Usuario GNU/Linux 234800 Maracay - Venezuela http://g013m.com.ve
participants (2)
-
Christian Sánchez -
Deepak Gulati