Use DBI exclusively to have a fine control of the produced queries. dbic requires a lot of symbols permutation to produce the desired ones.
30 lines
512 B
Perl
30 lines
512 B
Perl
package Pooru::API::V0::Model::Results;
|
|
use v5.40;
|
|
|
|
|
|
sub new ($class, $sth, $slice, @bind_values)
|
|
{
|
|
my $self = {
|
|
_sth => $sth,
|
|
_slice => $slice,
|
|
_bind_values => [@bind_values],
|
|
};
|
|
|
|
return bless $self, $class;
|
|
}
|
|
|
|
sub fetchall ($self, $slice = $self->{_slice})
|
|
{
|
|
$self->{_sth}->execute($self->{_bind_values}->@*);
|
|
|
|
return $self->{_sth}->fetchall_arrayref($slice);
|
|
}
|
|
|
|
sub single ($self, $slice = $self->{_slice})
|
|
{
|
|
my $rows = $self->fetchall($slice);
|
|
|
|
return $rows->@* == 1 ? $rows->[0] : undef;
|
|
}
|
|
|
|
1;
|