1 package DBIx::Class::Storage::Statistics;
4 use base qw/DBIx::Class::AccessorGroup Class::Data::Accessor/;
5 __PACKAGE__->mk_group_accessors(simple => qw/callback debugfh/);
9 DBIx::Class::Storage::Statistics - SQL Statistics
15 This class is called by DBIx::Class::Storage::DBI as a means of collecting
16 statistics on it's actions. Using this class alone merely prints the SQL
17 executed, the fact that it completes and begin/end notification for
20 To really use this class you should subclass it and create your own method
21 for collecting the statistics as discussed in L<DBIx::Class::Manual::Cookbook>.
29 Returns a new L<DBIx::Class::Storage::Statistics> object.
34 bless $self, (ref($_[0]) || $_[0]);
41 Sets or retrieves the filehandle used for trace/debug output. This should
42 be an IO::Handle compatible object (only the C<print> method is used). Initially
43 should be set to STDERR - although see information on the
44 L<DBIC_TRACE> environment variable.
48 Called when a transaction begins.
54 $self->debugfh->print("BEGIN WORK\n");
59 Called when a transaction is rolled back.
65 $self->debugfh->print("ROLLBACK\n");
70 Called when a transaction is committed.
76 $self->debugfh->print("COMMIT\n");
81 Called before a query is executed. The first argument is the SQL string being
82 executed and subsequent arguments are the parameters used for the query.
86 my ($self, $string, @bind) = @_;
88 my $message = "$string: ".join(', ', @bind)."\n";
90 if(defined($self->callback)) {
92 $self->callback->($1, $message);
96 $self->debugfh->print($message);
101 Called when a query finishes executing. Has the same arguments as query_start.
105 my ($self, $string) = @_;
112 Cory G. Watson <gphat@cpan.org>
116 You may distribute this code under the same license as Perl itself.