如何在 Perl 中获取数组数组?

How to fetch an array of arrays in Perl?

我试图在 Perl 中获取一些数组,但出现数据库错误,但在调试中我可以看到正确的值。

my $worker_names = $self->glpi->db->query(
        'select user_name from report_users'
    );
 
    my @all = @{$worker_names->arrays->flatten->to_array};
 
    if ($worker_name ne '') {
        @all = ( $worker_name );
    }
 
    # name => [ public, privat, phabricator ]
    my $table;
    for my $user_name (@all) {
        $table->{$user_name}->[0] = '00 Stunden 00 Minuten';
        $table->{$user_name}->[1] = '00 Stunden 00 Minuten';
        $table->{$user_name}->[2] = '00 Stunden 00 Minuten';
    }
 
    $glpi_hours->hashes->each( sub {
        my $row = $_[0];
 
        $table->{$row->{'name'}}->[0] = $row->{'public_actiontime'};
        $table->{$row->{'name'}}->[1] = $row->{'private_actiontime'};
    });
 
    $phabricator_hours->hashes->each( sub {
        my $row = $_[0];
 
        $table->{$row->{'name'}}->[2] = $row->{'phab_time'};
    });

我收到错误:

DBD::mysql::st fetchrow_hashref failed: fetch() without execute() at /var/www/perl5/perlbrew/perls/perl-5.28.3/lib/site_perl/5.28.3/Mojo/mysql/Results.pm line 55.       
  # Fetch sql data
52
  my $hash = $to->{type} eq 'hash';
53   
  my $sql_data
54
    = $to->{list} && $hash ? $self->sth->fetchall_arrayref({})
55  
    : $to->{list}          ? $self->sth->fetchall_arrayref
56   
    : $hash                ? [$self->sth->fetchrow_hashref]
57
    :                        [$self->sth->fetchrow_arrayref];
58
59
  # Optionally expand
60
  if ($mode) {

问题是数组 my @all = @{$worker_names->arrays->flatten->to_array}; 没有正常工作。 我也使用 mojolicious 作为框架。

当我 运行 在我的浏览器中时,我可以看到提取的值,首先是错误,然后是存储中的值。

问题是结果为空,因为我将值赋给数组,通过集合,结果保持为空。