SEARCH
NEW RPMS
DIRECTORIES
ABOUT
FAQ
VARIOUS
BLOG
DONATE


YUM REPOSITORY

 
 

MAN page from openSUSE Leap 15 perl-Mojo-Pg-4.13-lp151.38.1.noarch.rpm

Mojo::Pg::Results

Section: User Contributed Perl Documentation (3)
Updated: 2019-01-21
Index 

NAME

Mojo::Pg::Results - Results 

SYNOPSIS

  use Mojo::Pg::Results;  my $results = Mojo::Pg::Results->new(sth => $sth);  $results->hashes->map(sub { $_->{foo} })->shuffle->join("\n")->say;
 

DESCRIPTION

Mojo::Pg::Results is a container for DBD::Pg statement handles used byMojo::Pg::Database. 

ATTRIBUTES

Mojo::Pg::Results implements the following attributes. 

db

  my $db   = $results->db;  $results = $results->db(Mojo::Pg::Database->new);

Mojo::Pg::Database object these results belong to. 

sth

  my $sth  = $results->sth;  $results = $results->sth($sth);

DBD::Pg statement handle results are fetched from. 

METHODS

Mojo::Pg::Results inherits all methods from Mojo::Base and implements thefollowing new ones. 

array

  my $array = $results->array;

Fetch next row from ``sth'' and return it as an array reference. Note that``finish'' needs to be called if you are not fetching all the possible rows.

  # Process one row at a time  while (my $next = $results->array) {    say $next->[3];  }
 

arrays

  my $collection = $results->arrays;

Fetch all rows from ``sth'' and return them as a Mojo::Collection objectcontaining array references.

  # Process all rows at once  say $results->arrays->reduce(sub { $a + $b->[3] }, 0);
 

columns

  my $columns = $results->columns;

Return column names as an array reference.

  # Names of all columns  say for @{$results->columns};
 

expand

  $results = $results->expand;

Decode "json" and "jsonb" fields automatically to Perl values for all rows.

  # Expand JSON  $results->expand->hashes->map(sub { $_->{foo}{bar} })->join("\n")->say;
 

finish

  $results->finish;

Indicate that you are finished with ``sth'' and will not be fetching all theremaining rows. 

hash

  my $hash = $results->hash;

Fetch next row from ``sth'' and return it as a hash reference. Note that``finish'' needs to be called if you are not fetching all the possible rows.

  # Process one row at a time  while (my $next = $results->hash) {    say $next->{money};  }
 

hashes

  my $collection = $results->hashes;

Fetch all rows from ``sth'' and return them as a Mojo::Collection objectcontaining hash references.

  # Process all rows at once  say $results->hashes->reduce(sub { $a + $b->{money} }, 0);
 

new

  my $results = Mojo::Pg::Results->new;  my $results = Mojo::Pg::Results->new(sth => $sth);  my $results = Mojo::Pg::Results->new({sth => $sth});

Construct a new Mojo::Pg::Results object. 

rows

  my $num = $results->rows;

Number of rows. 

text

  my $text = $results->text;

Fetch all rows from ``sth'' and turn them into a table with``tablify'' in Mojo::Util. 

SEE ALSO

Mojo::Pg, Mojolicious::Guides, <https://mojolicious.org>.


 

Index

NAME
SYNOPSIS
DESCRIPTION
ATTRIBUTES
db
sth
METHODS
array
arrays
columns
expand
finish
hash
hashes
new
rows
text
SEE ALSO

This document was created byman2html,using the manual pages.