package Padre::DB::History;
# NOTE: This class is loaded automatically by Padre::DB, overlaying the
# code already auto-generated by Padre::DB. Do not load manually, as this
# module will not function standalone.
# NOTE: Portable Perl support is NOT required for this class, as the use
# of it is shared between many different modules. If any consumer of this
# module needs Portable Support, they will need to implement it themselves.
use 5.008;
use strict;
use warnings;
use Params::Util ();
our $VERSION = '0.96';
sub recent {
my $class = shift;
my $type = shift;
my $limit = Params::Util::_POSINT(shift) || 10;
my $recent = Padre::DB->selectcol_arrayref(
'select distinct name from history where type = ? order by id desc limit ?',
{}, $type, $limit
) or die 'Failed to find recent values from history';
return wantarray ? @$recent : $recent;
}
sub previous {
my $class = shift;
my @list = $class->recent( $_[0], 1 );
return $list[0];
}
1;
__END__
=pod
=head1 NAME
Padre::DB::History - Padre::DB class for the history table
=head1 SYNOPSIS
TO BE COMPLETED
=head1 DESCRIPTION
TO BE COMPLETED
=head1 METHODS
=head2 base
# Returns 'Padre::DB'
my $namespace = Padre::DB::History->base;
Normally you will only need to work directly with a table class,
and only with one ORLite package.
However, if for some reason you need to work with multiple ORLite packages
at the same time without hardcoding the root namespace all the time, you
can determine the root namespace from an object or table class with the
C method.
=head2 table
# Returns 'history'
print Padre::DB::History->table;
While you should not need the name of table for any simple operations,
from time to time you may need it programatically. If you do need it,
you can use the C
method to get the table name.
=head2 load
my $object = Padre::DB::History->load( $id );
If your table has single column primary key, a C method will be
generated in the class. If there is no primary key, the method is not
created.
The C method provides a shortcut mechanism for fetching a single
object based on the value of the primary key. However it should only
be used for cases where your code trusts the record to already exists.
It returns a C object, or throws an exception if the
object does not exist.
=head2 select
# Get all objects in list context
my @list = Padre::DB::History->select;
# Get a subset of objects in scalar context
my $array_ref = Padre::DB::History->select(
'where id > ? order by id',
1000,
);
The C