Skip to content

Instantly share code, notes, and snippets.

@sinkovsky
Created December 26, 2010 00:13
Show Gist options
  • Save sinkovsky/755118 to your computer and use it in GitHub Desktop.
Save sinkovsky/755118 to your computer and use it in GitHub Desktop.
my $users_sth = $self->app->dbh->prepare("SELECT
u.fullname, tu.user_type
FROM
report_template_users tu
JOIN
users u
ON tu.user_id = u.id
WHERE report_template_id = ?");
$users_sth->execute($row->{id});
my @users;
while ( my $user_row = $users_sth->fetchrow_hashref ) {
push @users, $user_row;
}
my @senders = map { $_->{fullname} } grep { $_->{user_type} eq 'sender' } @users;
my @recipients = map { $_->{fullname} } grep { $_->{user_type} eq 'recipient' } @users;
$row->{senders_str} = join ",", @senders;
$row->{recipients_str} = join ",", @recipients;
push @reports, $row;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment