DBIx::Class::QueryLog::Query - A Query


DBIx-Class-QueryLog documentation Contained in the DBIx-Class-QueryLog distribution.

Index


Code Index:

NAME

Top

DBIx::Class::QueryLog::Query - A Query

SYNOPSIS

Top

Represents a query. The sql, parameters, start time and end time are stored.

METHODS

Top

bucket

The bucket this query is in.

start_time

Time this query started.

end_time

Time this query ended.

sql

SQL for this query.

params

Parameters used with this query.

time_elapsed

Time this query took to execute. start - end.

count

Returns 1. Exists to make it easier for QueryLog to get a count of queries executed.

queries

Returns this query, here to make QueryLog's job easier.

get_sorted_queries

Returns this query. Here to make QueryLog's job easier.

AUTHOR

Top

Cory G Watson, <gphat at cpan.org>

ACKNOWLEDGEMENTS

Top

COPYRIGHT & LICENSE

Top


DBIx-Class-QueryLog documentation Contained in the DBIx-Class-QueryLog distribution.
package DBIx::Class::QueryLog::Query;
use Moose;

has bucket => (
    is => 'rw',
    isa => 'Str'
);

has end_time => (
    is => 'rw',
    isa => 'Num'
);

has params => (
    is => 'rw',
    isa => 'ArrayRef'
);

has sql => (
    is => 'rw',
    isa => 'Str'
);

has start_time => (
    is => 'rw',
    isa => 'Num'
);

sub time_elapsed {
	my $self = shift;

	return $self->end_time - $self->start_time;
}

sub count {

    return 1;
}

sub queries {
    my $self = shift;

    return [ $self ];
}

sub get_sorted_queries {
    my ($self, $sql) = @_;

    if(defined($sql)) {
        if($self->sql eq $sql) {
            return [ $self ];
        } else {
            return [  ];
        }
    }

    return [ $self ];
}

__PACKAGE__->meta->make_immutable;

1;