DBIx :: Class和Searching

时间:2013-03-19 17:59:32

标签: perl catalyst dbix-class

我想回到今天的生日。这就是我现在所拥有的,它有效,但我需要抓住月份和日期来输入声明。我想也许我可以从当地时间抓住它们,但这没有用。任何建议将不胜感激。

sub author_birth {
    my ($self) = @_;
    my ($day,$month) = (localtime())[3..4];
    my $author_result = $self->search_like(
        {
            birth => '%03-20'
        },
        {
            select => [
                'id',
                'complete_name',
            ],

            #result_class => 'DBIx::Class::ResultClass::HashRefInflator'
        }
    );

    my @author_ids = ();
    while (my $row = $author_result->next) {
        push @author_ids, $row->id;
    }

    return $self->get_author_info_by_id(\@author_ids);

}

1 个答案:

答案 0 :(得分:2)

我最终做了类似的事情。

my ($self) = @_;
my $conc = '%';
my $datetime = Time::Piece->new->strftime('%m-%d');
my $date = $conc . $datetime;
my $author_result = $self->search_like(
    {
        birth => $date,
    },
    {
        select => [
            'id',
            'complete_name',
        ],

        #result_class => 'DBIx::Class::ResultClass::HashRefInflator'
    }
);