1 package DBIx::Class::Storage::DBI::Role::QueryCounter;
4 requires '_query_start';
8 DBIx::Class::Storage::DBI::Role::QueryCounter; Role to add a query counter
12 my $query_count = $schema->storage->query_count;
16 Each time the schema does a query, increment the counter.
20 This package defines the following attributes.
24 Is the attribute holding the current query count. It defines a public reader
25 called 'query_count' which you can use to access the total number of queries
26 that DBIC has run since connection.
30 has '_query_count' => (
31 reader=>'query_count',
32 writer=>'_set_query_count',
41 This module defines the following methods.
45 override on the method so that we count the queries.
49 around '_query_start' => sub {
50 my ($_query_start, $self, @args) = @_;
51 $self->_increment_query_count;
52 return $self->$_query_start(@args);
56 =head2 _increment_query_count
58 Used internally. You won't need this unless you enjoy messing with the query
63 sub _increment_query_count {
65 my $current = $self->query_count;
66 $self->_set_query_count(++$current);
72 See L<DBIx::Class> for more information regarding authors.
76 You may distribute this code under the same terms as Perl itself.