Beefy Boxes and Bandwidth Generously Provided by pair Networks
RobOMonk Perl-Sensitive Sunglasses  Re: Can DBI modify queries
on the fly?  by kyle (Abbot) on Oct 14, 2009 at 18:41 UTC
( #801169=note: print w/ replies, xml ) Need Help??  in reply to
Can DBI modify queries on the fly?  Here's a solution that
doesn't use the callback mechanism, so it works with older
versions of DBI. To use it, give it as the RootClass to
DBI->connect. Since we were already using DBIx::ContextualFetch
there, the code below uses that as its base, but it's not
otherwise required.  package My::DatabaseRoot; use strict; use
warnings; use base 'DBIx::ContextualFetch'; package
My::DatabaseRoot::db; use base 'DBIx::ContextualFetch::db'; sub
_rewrite { return $_[0] if ! defined $_[0]; return $_[0] if
$_[0] =~ m{ COMPANY \s DEBUGGING \s INFO }xms; my $new_req =
shift @_; # Add a newline, if there isn't one. $new_req =~ s{
([^\n]) \z }{$1\n}xms; $new_req .= "/* COMPANY DEBUGGING
INFO\n"; my $frame_num = 1; while ( my @frame_info = caller(