NAME
Mojo::MySQL5::Results - Results
SYNOPSIS
my $results = Mojo::MySQL5::Results->new( db => $db );
|
DESCRIPTION
Mojo::MySQL5::Results is a container for results returned by call to $db->"query" in Mojo::MySQL5::Database.
METHODS
Mojo::MySQL5::Results inherits all methods from Mojo::Base and implements the following ones.
array
my $array = $results ->array;
|
Fetch one row and return it as an array reference.
while ( my $next = $results ->array) {
say $next ->[3];
}
|
arrays
my $collection = $results ->arrays;
|
Fetch all rows and return them as a Mojo::Collection object containing array references.
say $results ->arrays->reduce( sub { $a ->[3] + $b ->[3] });
|
columns
my $columns = $results ->columns;
|
Return column names as an array reference.
hash
my $hash = $results ->hash;
|
Fetch one row and return it as a hash reference.
while ( my $next = $results ->hash) {
say $next ->{money};
}
|
hashes
my $collection = $results ->hashes;
|
Fetch all rows and return them as a Mojo::Collection object containing hash references.
say $results ->hashes->reduce( sub { $a ->{money} + $b ->{money} });
|
rows
my $num = $results ->rows;
|
Number of rows.
text
my $text = $results ->text;
|
Fetch all rows and turn them into a table with "tablify" in Mojo::Util.
more_results
do {
my $columns = $results ->columns;
my $arrays = $results ->arrays;
} while ( $results ->more_results);
|
Handle multiple results.
affected_rows
my $affected = $results ->affected_rows;
|
Number of affected rows by the query. The number reported is dependant from found_rows
option in Mojo::MySQL5. For example
UPDATE $table SET id = 1 WHERE id = 1
|
would return 1 if found_rows
is set, and 0 otherwise.
last_insert_id
my $last_id = $results ->last_insert_id;
|
That value of AUTO_INCREMENT
column if executed query was INSERT
in a table with AUTO_INCREMENT
column.
warnings_count
my $warnings = $results ->warnings_count;
|
Number of warnings raised by the executed query.
err
Error code receieved.
state
my $state = $results ->state;
|
Error state receieved.
errstr
my $errstr = $results ->errstr;
|
Error message receieved.
SEE ALSO
Mojo::MySQL5, Mojo::MySQL5::Database.