【发布时间】:2017-11-14 02:24:37
【问题描述】:
我需要传递结果
Mojo::mysql
到 HTML 中的$variable
#!/usr/bin/env perl
use Mojolicious::Lite;
use Mojo::mysql;
helper mysql => sub {
state $pg = Mojo::mysql->new( 'mysql://mysql://sri:s3cret@localhost/db' )
};
get '/index' => sub {
my $c = shift;
my $db = $c->mysql->db;
$db->query( 'select now() as time' )->hash;
};
app->start;
__DATA__
@@ index.html.ep
<!DOCTYPE html>
<html>
<head><title><%= title %></title></head>
<body><%= $db %></body>
</html>`
我需要将$db 的结果传递给索引,但我不知道该怎么做。
【问题讨论】:
标签: perl mojolicious