SEARCH
NEW RPMS
DIRECTORIES
ABOUT
FAQ
VARIOUS
BLOG
DONATE


YUM REPOSITORY

 
 

MAN page from OpenSuSE perl-Mojo-SQLite-2.002-10.1.noarch.rpm

Mojo::SQLite::Results

Section: User Contributed Perl Documentation (3pm)
Updated: 2017-06-01
Index 

NAME

Mojo::SQLite::Results - Results 

SYNOPSIS

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

DESCRIPTION

Mojo::SQLite::Results is a container for DBD::SQLite statement handlesused by Mojo::SQLite::Database. 

ATTRIBUTES

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

sth

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

DBD::SQLite statement handle results are fetched from. 

METHODS

Mojo::SQLite::Results inherits all methods from Mojo::Base and implementsthe following new ones. 

new

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

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

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->[3] + $b->[3] });
 

columns

  my $columns = $results->columns;

Return column names as an array reference.

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

expand

  $results = $results->expand(json => 'some_json');  $results = $results->expand(json => ['some_json','other_json']);

Decode specified fields from a particular format to Perl values for all rows.Currently only the "json" text format is recognized. The names must exactlymatch the column names as returned by ``columns''; it is recommended to useexplicit aliases in the query for consistent column names.

  # Expand JSON  $results->expand(json => 'json_field')->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->{money} + $b->{money} });
 

last_insert_id

  my $id = $results->last_insert_id;

Returns the rowid <https://www.sqlite.org/c3ref/last_insert_rowid.html> of themost recent successful "INSERT". 

rows

  my $num = $results->rows;

Number of rows. Note that for "SELECT" statements, this count will not beaccurate until all rows have been fetched. 

text

  my $text = $results->text;

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

BUGS

Report any issues on the public bugtracker. 

AUTHOR

Dan Book, "dbookAATTcpan.org" 

COPYRIGHT AND LICENSE

Copyright 2015, Dan Book.

This library is free software; you may redistribute it and/or modify it underthe terms of the Artistic License version 2.0. 

SEE ALSO

Mojo::SQLite


 

Index

NAME
SYNOPSIS
DESCRIPTION
ATTRIBUTES
sth
METHODS
new
array
arrays
columns
expand
finish
hash
hashes
last_insert_id
rows
text
BUGS
AUTHOR
COPYRIGHT AND LICENSE
SEE ALSO

This document was created byman2html,using the manual pages.