NAME
DBIx::QuickORM::Handle::Column - Aggregate and single-column reads for a handle.
DESCRIPTION
A thin wrapper binding a DBIx::QuickORM::Handle to one column (or column expression) so you can read aggregates over it (sum/min/max/avg/ count/func) or pull the column's values directly (all/iterator).
Obtain one from a handle:
my $col = $con->handle('orders')->where({paid => 1})->column('total');
Every fetch runs a single SELECT that reuses the handle's where (and any group_by/having), returns the raw database scalar (no type inflation, like count()), and never enters the identity map.
SYNOPSIS
my $orders = $con->handle('orders');
my $total = $orders->column('total')->sum;
my $biggest = $orders->column('total')->max;
my $joined = $orders->column('sku')->func('GROUP_CONCAT');
# Literal expression (emitted verbatim):
my $revenue = $orders->column(\'price * qty')->sum;
# Per-group values line up with a grouped handle:
my @totals = $orders->group_by('category')->column('total')->all;
ATTRIBUTES
- handle
-
The DBIx::QuickORM::Handle this column reads through.
- column
-
The column: a plain string name, or a scalar reference holding literal SQL.
PUBLIC METHODS
- $val = $col->sum
- $val = $col->min
- $val = $col->max
- $val = $col->avg
- $val = $col->count
-
Run the matching SQL aggregate over the column and return the scalar result (
undefwhen there are no rows). - $val = $col->func($name)
-
Run an arbitrary single-argument aggregate
$nameover the column (e.g.$col->func('GROUP_CONCAT')). The function name must be a bare identifier (word characters only). - @vals = $col->all
-
The column's value from every row, as a list of plain scalars.
- $iter = $col->iterator
-
An iterator yielding the column's value one row at a time.
PRIVATE METHODS
- $val = $col->_aggregate($func)
-
Apply an aggregate function to the column expression and fetch the scalar.
- $sql = $col->_column_sql
-
The column rendered as SQL: a quoted identifier for a plain name, or the literal SQL verbatim for a scalar reference.
SOURCE
The source code repository for DBIx::QuickORM can be found at https://github.com/exodist/DBIx-QuickORM.
MAINTAINERS
AUTHORS
COPYRIGHT
Copyright Chad Granum <exodist7@gmail.com>.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.