OpenResty::SQL::Statement - Base class for the various SQL generator classes


OpenResty documentation Contained in the OpenResty distribution.

Index


Code Index:

NAME

Top

OpenResty::SQL::Statement - Base class for the various SQL generator classes

DESCRIPTION

Top

AUTHOR

Top

Agent Zhang (agentzh) <agentzh@yahoo.cn>

SEE ALSO

Top

OpenResty::SQL::Select, OpenResty::SQL::Insert, OpenResty::SQL::Update, OpenResty.


OpenResty documentation Contained in the OpenResty distribution.

package OpenResty::SQL::Statement;

use strict;
use warnings;
use base 'Clone';
use overload '""' => sub { $_[0]->generate };

sub reset {
    my $self = shift;
    %$self = %{ $self->new(@_) };
    $self;
}

sub where {
    my $self = shift;
    if (@_ == 2) {
        push @{ $self->{where} }, [$_[0], '=', $_[1]];
    } else {
        push @{ $self->{where} }, [@_];
    }
    $self;
}

1;
__END__