|
NAMEMojo::Pg::Results - ResultsSYNOPSISuse Mojo::Pg::Results; my $results = Mojo::Pg::Results->new(sth => $sth); $results->hashes->map(sub { $_->{foo} })->shuffle->join("\n")->say; DESCRIPTIONMojo::Pg::Results is a container for DBD::Pg statement handles used by Mojo::Pg::Database.ATTRIBUTESMojo::Pg::Results implements the following attributes.dbmy $db = $results->db; $results = $results->db(Mojo::Pg::Database->new); Mojo::Pg::Database object these results belong to. sthmy $sth = $results->sth; $results = $results->sth($sth); DBD::Pg statement handle results are fetched from. METHODSMojo::Pg::Results inherits all methods from Mojo::Base and implements the following new ones.arraymy $array = $results->array; Fetch one row from "sth" and return it as an array reference. arraysmy $collection = $results->arrays; Fetch all rows from "sth" and return them as a Mojo::Collection object containing array references. # Process all rows at once say $results->arrays->reduce(sub { $a + $b->[3] }, 0); columnsmy $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 the remaining rows. hashmy $hash = $results->hash; Fetch one row from "sth" and return it as a hash reference. hashesmy $collection = $results->hashes; Fetch all rows from "sth" and return them as a Mojo::Collection object containing hash references. # Process all rows at once say $results->hashes->reduce(sub { $a + $b->{money} }, 0); newmy $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. rowsmy $num = $results->rows; Number of rows. textmy $text = $results->text; Fetch all rows from "sth" and turn them into a table with "tablify" in Mojo::Util. SEE ALSOMojo::Pg, Mojolicious::Guides, <https://mojolicious.org>.
Visit the GSP FreeBSD Man Page Interface. |