I run this
use Mojolicious::Lite;
use EV;
use DBIx::Custom;
my $dbi = DBIx::Custom->connect(dsn =>
'dbi:mysql:database=dbix_custom',user=>'user1',password=>'password1',connector
=> 1);
$dbi->async_conf({
prepare_attr => {async => 1},
fh => sub { shift->dbh->mysql_fd }
});
get '/non-blocking' => sub {
my $self = shift;
$self->render_later;
$dbi->execute('SELECT name, SUM(age) FROM people GROUP BY name', undef,
select => 1,
async => sub {
my ($dbi, $result) = @_;
my $rows = $result->fetch_all;
$self->render('index', rows => $rows );
}
);
};
get '/blocking' => sub {
my $self = shift;
$self->render(text => $dbi->select('SLEEP(5), (FLOOR( 1 + RAND( ) *
1000 ))')->fetch_one->[1]);
};
app->secret('Mojolicious rocks and Alex rocks');
app->start;
__DATA__
@@ index.html.ep
<!DOCTYPE html>
<html>
<head>
<title>People</title>
</head>
<body>
<br>
Data: <br>
<table border="1">
<thead>
<tr>
<th>Name</th>
<th>Age</th>
</tr>
</thead>
<tbody id="table">
%= include 'table'
</tbody>
</table>
</body>
</html>
@@ table.html.ep
% foreach my $row (@$rows) {
<tr>
% foreach my $text (@$row) {
<td><%= $text %></td>
% }
</tr>
% }
but after some time I got
EV: error in callback (ignoring): DBD::mysql::st fetchrow_array failed:
fetch() without execute() at
/usr/local/share/perl/5.10.1/DBIx/Custom/Result.pm line 19.
What happen?
On 7 July 2013 05:15, Yuki Kimoto via RT <bug-DBIx-Custom@rt.cpan.org>wrote:
Show quoted text> <URL:
https://rt.cpan.org/Ticket/Display.html?id=86755 >
>
> thanks.
>
> Sorry, I can't solve this problem.
>
> please ask Mojolicious author sri.
>
> the following code has same result.
>
> get '/timer' => sub {
> my $self = shift;
>
> Mojo::IOLoop->timer(1 => sub {
> $self->render(text => 'Hello');
> });
>
> $self->render_later;
> };
>
>
> 2013/7/7 Alex Marenco via RT <bug-DBIx-Custom@rt.cpan.org>
>
> > Sat Jul 06 18:32:32 2013: Request 86755 was acted upon.
> > Transaction: Ticket created by alex.marenco@gmail.com
> > Queue: DBIx-Custom
> > Subject: EV Problem
> > Broken in: (no value)
> > Severity: (no value)
> > Owner: Nobody
> > Requestors: alex.marenco@gmail.com
> > Status: new
> > Ticket <URL:
https://rt.cpan.org/Ticket/Display.html?id=86755 >
> >
> >
> > Why if I run this example
> >
> > use Mojolicious::Lite;
> > use EV;
> > use DBIx::Custom;
> > my $dbi = DBIx::Custom->connect(dsn => 'dbi:mysql:database=usertest',
> > user=>'user1',password=>'password1',connector => 1);
> > $dbi->async_conf({
> > prepare_attr => {async => 1},
> > fh => sub { shift->dbh->mysql_fd }
> > });
> > get '/non-blocking' => sub {
> > my $self = shift;
> > $self->render_later;
> > $dbi->select('SLEEP(1), (FLOOR( 1 + RAND( ) * 1000 ))', async => sub
> {
> > my ($dbi, $result) = @_;
> > my $row = $result->fetch_one;
> > $self->render(text => $row->[1]);
> > });
> > };
> > get '/blocking' => sub {
> > my $self = shift;
> > $self->render(text => $dbi->select('SLEEP(5), (FLOOR( 1 + RAND( ) *
> > 1000 ))')->fetch_one->[1]);
> > };
> > app->start;
> >
> > on google chrome (
http://192.168.0.2:3000/non-blocking) and I press F5
> > (refresh) many times I got
> >
> > EV: error in callback (ignoring): Can't call method "res" on an undefined
> > value at /usr/local/share/perl/5.10.1/Mojolicious/Controller.pm line 260.
> >
> > What is the problem?
> >
> > Thank You.
> >
> >
>
>