Author: spadkins
Date: Wed Aug 15 14:51:17 2007
New Revision: 9842

Modified:
   p5ee/trunk/App-Repository/lib/App/Repository/DBI.pm
   p5ee/trunk/App-Repository/lib/App/Repository/MySQL.pm

Log:
change debug_sql and all other debug-style output to obey the debug_file option

Modified: p5ee/trunk/App-Repository/lib/App/Repository/DBI.pm
==============================================================================
--- p5ee/trunk/App-Repository/lib/App/Repository/DBI.pm (original)
+++ p5ee/trunk/App-Repository/lib/App/Repository/DBI.pm Wed Aug 15 14:51:17 2007
@@ -403,8 +403,8 @@
     my ($timer, $elapsed_time);
     if ($debug_sql) {
         $timer = $self->_get_timer();
-        print "DEBUG_SQL: _get_row()\n";
-        print $sql;
+        print $App::DEBUG_FILE "DEBUG_SQL: _get_row()\n";
+        print $App::DEBUG_FILE $sql;
     }
     if ($context_options->{explain_sql}) {
         $self->explain_sql($sql);
@@ -433,11 +433,11 @@
     }
     if ($debug_sql) {
         $elapsed_time = $self->_read_timer($timer);
-        print "DEBUG_SQL: nrows [", (defined $row ? 1 : 0), "] ($elapsed_time 
sec) $DBI::errstr\n";
+        print $App::DEBUG_FILE "DEBUG_SQL: nrows [", (defined $row ? 1 : 0), 
"] ($elapsed_time sec) $DBI::errstr\n";
         if ($debug_sql >= 2) {
-            print "DEBUG_SQL: [", ($row ? join("|",map { defined $_ ? $_ : 
"undef" } @$row) : ""), "]\n";
+            print $App::DEBUG_FILE "DEBUG_SQL: [", ($row ? join("|",map { 
defined $_ ? $_ : "undef" } @$row) : ""), "]\n";
         }
-        print "\n";
+        print $App::DEBUG_FILE "\n";
     }
 
     &App::sub_exit($row) if ($App::trace);
@@ -449,7 +449,10 @@
     my ($self, $table, $params, $cols, $options) = @_;
 
     my ($sql, $rows, $startrow, $endrow);
-    if ($self->{table}{$table}{rawaccess}) {
+    my $table_def = $self->get_table_def($table);
+    #print $App::DEBUG_FILE "DBI._get_rows : table=[$table] 
rawaccess=[$table_def->{rawaccess}]\n";
+    #if ($self->{table}{$table}{rawaccess}) {
+    if ($table_def->{rawaccess}) {
         $sql = $self->_mk_select_sql($table, $params, $cols, $options);
     }
     else {
@@ -469,8 +472,8 @@
     my ($timer, $elapsed_time);
     if ($debug_sql) {
         $timer = $self->_get_timer();
-        print "DEBUG_SQL: _get_rows()\n";
-        print $sql;
+        print $App::DEBUG_FILE "DEBUG_SQL: _get_rows()\n";
+        print $App::DEBUG_FILE $sql;
     }
     if ($context_options->{explain_sql}) {
         $self->explain_sql($sql);
@@ -498,13 +501,13 @@
     }
     if ($debug_sql) {
         $elapsed_time = $self->_read_timer($timer);
-        print "DEBUG_SQL: nrows [", (defined $rows ? ($#$rows+1) : 0), "] 
($elapsed_time sec) $DBI::errstr\n";
+        print $App::DEBUG_FILE "DEBUG_SQL: nrows [", (defined $rows ? 
($#$rows+1) : 0), "] ($elapsed_time sec) $DBI::errstr\n";
         if ($debug_sql >= 2) {
             foreach my $row (@$rows) {
-                print "DEBUG_SQL: [", join("|",map { defined $_ ? $_ : 
"undef"} @$row), "]\n";
+                print $App::DEBUG_FILE "DEBUG_SQL: [", join("|",map { defined 
$_ ? $_ : "undef"} @$row), "]\n";
             }
         }
-        print "\n";
+        print $App::DEBUG_FILE "\n";
     }
 
     &App::sub_exit($rows) if ($App::trace);
@@ -1244,7 +1247,7 @@
     # create initial where conditions for the selected rows
     ############################################################
 
-    #print $self->{context}->dump(), "\n";
+    #print $App::DEBUG_FILE $self->{context}->dump(), "\n";
 
     my %sqlop = (
         "contains"     => "like",
@@ -1548,7 +1551,7 @@
     my (@outer_join_clauses);
 
     foreach $tablealias (@$tablealiases) {
-        #print "checking table $tablealias\n";
+        #print $App::DEBUG_FILE "checking table $tablealias\n";
         if ($reqd_tables{$tablealias}) {
             $dbtable = $tablealiashref->{$tablealias}{table};
             $tableref = ($dbtable) ? "$dbtable $tablealias" : $tablealias;
@@ -1558,7 +1561,7 @@
             }
             if ($tablealiashref->{$tablealias}{cardinality_zero}) {
                 push(@outer_join_clauses, "left join $tableref on 
$where_condition") if ($where_condition);
-                #print "   $tablealias is [$dbtable] as [$tableref] where 
[$where_condition] (outer)\n";
+                #print $App::DEBUG_FILE "   $tablealias is [$dbtable] as 
[$tableref] where [$where_condition] (outer)\n";
             }
             else {
                 push(@join_conditions, split(/ +and +/,$where_condition)) if 
($where_condition);
@@ -1566,7 +1569,7 @@
                     $tableref .= " $tablealiashref->{$tablealias}{hint}";
                 }
                 push(@from_tables, $tableref);
-                #print "   $tablealias is [$dbtable] as [$tableref] where 
[$where_condition]\n";
+                #print $App::DEBUG_FILE "   $tablealias is [$dbtable] as 
[$tableref] where [$where_condition]\n";
             }
         }
     }
@@ -1649,7 +1652,7 @@
 sub _require_tables {
     &App::sub_entry if ($App::trace >= 3);
     my ($self, $dbexpr, $reqd_tables, $relationship_defs, $require_type) = @_;
-    #print "_require_tables($dbexpr,...,...,$require_type)\n";
+    #print $App::DEBUG_FILE "_require_tables($dbexpr,...,...,$require_type)\n";
     my ($relationship, $relationship2, @relationship, %tableseen, 
$dependencies);
     while ($dbexpr =~ s/([a-zA-Z_][a-zA-Z_0-9]*)\.[a-zA-Z_][a-zA-Z_0-9]*//) {
         if (defined $relationship_defs->{$1} && !$tableseen{$1}) {
@@ -1659,14 +1662,14 @@
         while ($relationship = pop(@relationship)) {
             if (! defined $reqd_tables->{$relationship}) {
                 $reqd_tables->{$relationship} = $require_type;
-                #print "table required: $relationship => $require_type\n";
+                #print $App::DEBUG_FILE "table required: $relationship => 
$require_type\n";
                 $dependencies = 
$relationship_defs->{$relationship}{dependencies};
                 push(@relationship, @$dependencies)
                    if (defined $dependencies && ref($dependencies) eq "ARRAY");
             }
             elsif ($reqd_tables->{$relationship} < $require_type) {
                 $reqd_tables->{$relationship} = $require_type;
-                #print "table required: $relationship => $require_type\n";
+                #print $App::DEBUG_FILE "table required: $relationship => 
$require_type\n";
             }
         }
     }
@@ -1682,7 +1685,7 @@
     my $dbh = $self->{dbh};
 
     my ($sql, $values, $col, $value, $colnum, $quoted);
-    #print "_mk_insert_row_sql($table,\n   [",
+    #print $App::DEBUG_FILE "_mk_insert_row_sql($table,\n   [",
     #    join(",",@$cols), "],\n   [",
     #    join(",",@$row), "])\n";
 
@@ -2176,9 +2179,9 @@
     my ($timer, $elapsed_time);
     if ($debug_sql) {
         $timer = $self->_get_timer();
-        print "DEBUG_SQL: insert()\n";
-        print "DEBUG_SQL: bind vars [", join("|",map { defined $_ ? $_ : 
"undef" } @$row), "]\n";
-        print $sql;
+        print $App::DEBUG_FILE "DEBUG_SQL: insert()\n";
+        print $App::DEBUG_FILE "DEBUG_SQL: bind vars [", join("|",map { 
defined $_ ? $_ : "undef" } @$row), "]\n";
+        print $App::DEBUG_FILE $sql;
     }
     if ($context_options->{explain_sql}) {
         $self->explain_sql($sql);
@@ -2186,8 +2189,8 @@
     $retval = $dbh->do($sql, undef, @$row) if (defined $dbh);
     if ($debug_sql && $debug_sql >= 2) {
         $elapsed_time = $self->_read_timer($timer);
-        print "DEBUG_SQL: retval [$retval] ($elapsed_time sec) $DBI::errstr\n";
-        print "\n";
+        print $App::DEBUG_FILE "DEBUG_SQL: retval [$retval] ($elapsed_time 
sec) $DBI::errstr\n";
+        print $App::DEBUG_FILE "\n";
     }
 
     &App::sub_exit($retval) if ($App::trace);
@@ -2217,17 +2220,17 @@
         $sql = $self->_mk_insert_row_sql($table, $cols);
         foreach my $row (@$rows) {
             if ($debug_sql) {
-                print "DEBUG_SQL: _insert_rows()\n";
-                print "DEBUG_SQL: bind vars [", join("|",map { defined $_ ? $_ 
: "undef" } @$row), "]\n";
-                print $sql;
+                print $App::DEBUG_FILE "DEBUG_SQL: _insert_rows()\n";
+                print $App::DEBUG_FILE "DEBUG_SQL: bind vars [", join("|",map 
{ defined $_ ? $_ : "undef" } @$row), "]\n";
+                print $App::DEBUG_FILE $sql;
             }
             if ($explain_sql) {
                 $self->explain_sql($sql);
             }
             $retval = $dbh->do($sql, undef, @$row);
             if ($debug_sql) {
-                print "DEBUG_SQL: retval [$retval] $DBI::errstr\n";
-                print "\n";
+                print $App::DEBUG_FILE "DEBUG_SQL: retval [$retval] 
$DBI::errstr\n";
+                print $App::DEBUG_FILE "\n";
             }
     
             if ($retval) {
@@ -2251,17 +2254,17 @@
             last if ($#$rows == -1);
             foreach my $row (@$rows) {
                 if ($debug_sql) {
-                    print "DEBUG_SQL: _insert_rows()\n";
-                    print "DEBUG_SQL: bind vars [", join("|",map { defined $_ 
? $_ : "undef" } @$row), "]\n";
-                    print $sql;
+                    print $App::DEBUG_FILE "DEBUG_SQL: _insert_rows()\n";
+                    print $App::DEBUG_FILE "DEBUG_SQL: bind vars [", 
join("|",map { defined $_ ? $_ : "undef" } @$row), "]\n";
+                    print $App::DEBUG_FILE $sql;
                 }
                 if ($context_options->{explain_sql}) {
                     $self->explain_sql($sql);
                 }
                 $retval = $dbh->do($sql, undef, @$row);
                 if ($debug_sql) {
-                    print "DEBUG_SQL: retval [$retval] $DBI::errstr\n";
-                    print "\n";
+                    print $App::DEBUG_FILE "DEBUG_SQL: retval [$retval] 
$DBI::errstr\n";
+                    print $App::DEBUG_FILE "\n";
                 }
         
                 if ($retval) {
@@ -2276,7 +2279,7 @@
     }
     if ($debug_sql) {
         $elapsed_time = $self->_read_timer($timer);
-        print "DEBUG_SQL: nrows [$nrows] ($elapsed_time sec)\n";
+        print $App::DEBUG_FILE "DEBUG_SQL: nrows [$nrows] ($elapsed_time 
sec)\n";
     }
     $self->{sql} = $sql;
     $self->{numrows} = $nrows;
@@ -2296,8 +2299,8 @@
     my ($timer, $elapsed_time);
     if ($debug_sql) {
         $timer = $self->_get_timer();
-        print "DEBUG_SQL: _delete()\n";
-        print $sql;
+        print $App::DEBUG_FILE "DEBUG_SQL: _delete()\n";
+        print $App::DEBUG_FILE $sql;
     }
     if ($context_options->{explain_sql}) {
         $self->explain_sql($sql);
@@ -2306,8 +2309,8 @@
     $retval = 0 if ($retval == 0); # turn "0E0" into plain old "0"
     if ($debug_sql) {
         $elapsed_time = $self->_read_timer($timer);
-        print "DEBUG_SQL: retval [$retval] ($elapsed_time sec) $DBI::errstr\n";
-        print "\n";
+        print $App::DEBUG_FILE "DEBUG_SQL: retval [$retval] ($elapsed_time 
sec) $DBI::errstr\n";
+        print $App::DEBUG_FILE "\n";
     }
 
     &App::sub_exit($retval) if ($App::trace);
@@ -2331,8 +2334,8 @@
     my ($timer, $elapsed_time);
     if ($debug_sql) {
         $timer = $self->_get_timer();
-        print "DEBUG_SQL: _update()\n";
-        print $sql;
+        print $App::DEBUG_FILE "DEBUG_SQL: _update()\n";
+        print $App::DEBUG_FILE $sql;
     }
     if ($context_options->{explain_sql}) {
         $self->explain_sql($sql);
@@ -2341,8 +2344,8 @@
     $retval = 0 if ($retval == 0); # turn "0E0" into plain old "0"
     if ($debug_sql) {
         $elapsed_time = $self->_read_timer($timer);
-        print "DEBUG_SQL: retval [$retval] ($elapsed_time sec) $DBI::errstr\n";
-        print "\n";
+        print $App::DEBUG_FILE "DEBUG_SQL: retval [$retval] ($elapsed_time 
sec) $DBI::errstr\n";
+        print $App::DEBUG_FILE "\n";
     }
 
     &App::sub_exit($retval) if ($App::trace);
@@ -2364,8 +2367,8 @@
     my ($timer, $elapsed_time);
     if ($debug_sql) {
         $timer = $self->_get_timer();
-        print "DEBUG_SQL: _delete_row()\n";
-        print $sql;
+        print $App::DEBUG_FILE "DEBUG_SQL: _delete_row()\n";
+        print $App::DEBUG_FILE $sql;
     }
     if ($context_options->{explain_sql}) {
         $self->explain_sql($sql);
@@ -2374,8 +2377,8 @@
     $retval = 0 if ($retval == 0); # turn "0E0" into plain old "0"
     if ($debug_sql) {
         $elapsed_time = $self->_read_timer($timer);
-        print "DEBUG_SQL: retval [$retval] ($elapsed_time sec) $DBI::errstr\n";
-        print "\n";
+        print $App::DEBUG_FILE "DEBUG_SQL: retval [$retval] ($elapsed_time 
sec) $DBI::errstr\n";
+        print $App::DEBUG_FILE "\n";
     }
 
     &App::sub_exit($retval) if ($App::trace);
@@ -2397,8 +2400,8 @@
     my ($timer, $elapsed_time);
     if ($debug_sql) {
         $timer = $self->_get_timer();
-        print "DEBUG_SQL: _delete_rows()\n";
-        print $sql;
+        print $App::DEBUG_FILE "DEBUG_SQL: _delete_rows()\n";
+        print $App::DEBUG_FILE $sql;
     }
     if ($context_options->{explain_sql}) {
         $self->explain_sql($sql);
@@ -2407,8 +2410,8 @@
     $retval = 0 if ($retval == 0); # turn "0E0" into plain old "0"
     if ($debug_sql) {
         $elapsed_time = $self->_read_timer($timer);
-        print "DEBUG_SQL: retval [$retval] ($elapsed_time sec) $DBI::errstr\n";
-        print "\n";
+        print $App::DEBUG_FILE "DEBUG_SQL: retval [$retval] ($elapsed_time 
sec) $DBI::errstr\n";
+        print $App::DEBUG_FILE "\n";
     }
 
     &App::sub_exit($retval) if ($App::trace);
@@ -2428,9 +2431,9 @@
     my ($timer, $elapsed_time);
     if ($debug_sql) {
         $timer = $self->_get_timer();
-        print "DEBUG_SQL: _do()\n";
-        print $sql;
-        print "\n" if ($sql !~ /\n$/);
+        print $App::DEBUG_FILE "DEBUG_SQL: _do()\n";
+        print $App::DEBUG_FILE $sql;
+        print $App::DEBUG_FILE "\n" if ($sql !~ /\n$/);
     }
     if ($context_options->{explain_sql}) {
         $self->explain_sql($sql);
@@ -2456,13 +2459,13 @@
             }
         }
         $elapsed_time = $self->_read_timer($timer);
-        print "DEBUG_SQL: nrows [$nrows] ($elapsed_time sec) $DBI::errstr\n";
+        print $App::DEBUG_FILE "DEBUG_SQL: nrows [$nrows] ($elapsed_time sec) 
$DBI::errstr\n";
         if ($debug_sql >= 2 && ref($retval)) {
             foreach my $row (@$retval) {
-                print "DEBUG_SQL: [", join("|",map { defined $_ ? $_ : 
"undef"} @$row), "]\n";
+                print $App::DEBUG_FILE "DEBUG_SQL: [", join("|",map { defined 
$_ ? $_ : "undef"} @$row), "]\n";
             }
         }
-        print "\n";
+        print $App::DEBUG_FILE "\n";
     }
 
     &App::sub_exit($retval) if ($App::trace);
@@ -3051,10 +3054,10 @@
     }
 
     #if ($App::DEBUG >= 2 && $self->{context}->dbg(2)) {
-    #    print "Table Metadata: $table\n";
+    #    print $App::DEBUG_FILE "Table Metadata: $table\n";
     #    my $d = Data::Dumper->new([ $table_def ], [ "table_def" ]);
     #    $d->Indent(1);
-    #    print $d->Dump();
+    #    print $App::DEBUG_FILE $d->Dump();
     #}
     &App::sub_exit() if ($App::trace);
 }

Modified: p5ee/trunk/App-Repository/lib/App/Repository/MySQL.pm
==============================================================================
--- p5ee/trunk/App-Repository/lib/App/Repository/MySQL.pm       (original)
+++ p5ee/trunk/App-Repository/lib/App/Repository/MySQL.pm       Wed Aug 15 
14:51:17 2007
@@ -133,7 +133,7 @@
     my $dbh = $self->{dbh};
 
     my ($sql, $values, $col, $value, $colnum, $quoted);
-    #print "_mk_insert_row_sql($table,\n   [",
+    #print $App::DEBUG_FILE "_mk_insert_row_sql($table,\n   [",
     #    join(",",@$cols), "],\n   [",
     #    join(",",@$row), "])\n";
 
@@ -309,13 +309,13 @@
 
             $sql = $self->_mk_insert_rows_sql($table, $cols, [EMAIL 
PROTECTED], $options);
             if ($debug_sql) {
-                print "DEBUG_SQL: _insert_rows()\n";
-                print $sql;
+                print $App::DEBUG_FILE "DEBUG_SQL: _insert_rows()\n";
+                print $App::DEBUG_FILE $sql;
             }
             $retval = $dbh->do($sql);
             if ($debug_sql) {
-                print "DEBUG_SQL: retval [$retval] $DBI::errstr\n";
-                print "\n";
+                print $App::DEBUG_FILE "DEBUG_SQL: retval [$retval] 
$DBI::errstr\n";
+                print $App::DEBUG_FILE "\n";
             }
 
             $nrows += $retval;
@@ -345,13 +345,13 @@
             last if ($#$rows == -1);
             $sql = $self->_mk_insert_rows_sql($table, $cols, $rows, $options);
             if ($debug_sql) {
-                print "DEBUG_SQL: _insert_rows()\n";
-                print $sql;
+                print $App::DEBUG_FILE "DEBUG_SQL: _insert_rows()\n";
+                print $App::DEBUG_FILE $sql;
             }
             $retval = $dbh->do($sql);
             if ($debug_sql) {
-                print "DEBUG_SQL: retval [$retval] $DBI::errstr\n";
-                print "\n";
+                print $App::DEBUG_FILE "DEBUG_SQL: retval [$retval] 
$DBI::errstr\n";
+                print $App::DEBUG_FILE "\n";
             }
 
             $nrows += $retval;
@@ -367,7 +367,7 @@
     }
     if ($debug_sql) {
         $elapsed_time = $self->_read_timer($timer);
-        print "DEBUG_SQL: total rows [$nrows] ($elapsed_time sec)\n";
+        print $App::DEBUG_FILE "DEBUG_SQL: total rows [$nrows] ($elapsed_time 
sec)\n";
     }
     $self->{sql} = $sql;
     $self->{numrows} = $nrows;
@@ -406,13 +406,13 @@
     if ($rows_ref eq "ARRAY") {
         $sql = $self->_mk_insert_rows_sql($table, $cols, $rows, $options);
         if ($debug_sql) {
-            print "DEBUG_SQL: _insert_rows()\n";
-            print $sql;
+            print $App::DEBUG_FILE "DEBUG_SQL: _insert_rows()\n";
+            print $App::DEBUG_FILE $sql;
         }
         $retval = $dbh->do($sql);
         if ($debug_sql) {
-            print "DEBUG_SQL: retval [$retval] $DBI::errstr\n";
-            print "\n";
+            print $App::DEBUG_FILE "DEBUG_SQL: retval [$retval] 
$DBI::errstr\n";
+            print $App::DEBUG_FILE "\n";
         }
 
         $nrows = $retval;
@@ -636,15 +636,15 @@
         my ($timer, $elapsed_time);
         if ($debug_sql) {
             $timer = $self->_get_timer();
-            print "DEBUG_SQL: import_rows()\n";
-            print $sql;
+            print $App::DEBUG_FILE "DEBUG_SQL: import_rows()\n";
+            print $App::DEBUG_FILE $sql;
         }
         eval {
             $nrows = $self->{dbh}->do($sql);
         };
         if ($debug_sql) {
             $elapsed_time = $self->_read_timer($timer);
-            print "DEBUG_SQL: import_rows=[$nrows] ($elapsed_time sec) 
$DBI::errstr : [EMAIL PROTECTED]";
+            print $App::DEBUG_FILE "DEBUG_SQL: import_rows=[$nrows] 
($elapsed_time sec) $DBI::errstr : [EMAIL PROTECTED]";
         }
         die $@ if ($@);
     }
@@ -734,8 +734,8 @@
         my ($timer, $elapsed_time);
         if ($debug_sql) {
             $timer = $self->_get_timer();
-            print "DEBUG_SQL: export_rows()\n";
-            print $sql;
+            print $App::DEBUG_FILE "DEBUG_SQL: export_rows()\n";
+            print $App::DEBUG_FILE $sql;
         }
         my ($retval);
         eval {
@@ -743,7 +743,7 @@
         };
         if ($debug_sql) {
             $elapsed_time = $self->_read_timer($timer);
-            print "DEBUG_SQL: export_rows=[$retval] ($elapsed_time sec) 
$DBI::errstr : [EMAIL PROTECTED]";
+            print $App::DEBUG_FILE "DEBUG_SQL: export_rows=[$retval] 
($elapsed_time sec) $DBI::errstr : [EMAIL PROTECTED]";
         }
     }
     
@@ -772,35 +772,35 @@
             eval {
                 $rows = $dbh->selectall_arrayref("explain $sql");
             };
-            print "EXPLAIN_SQL: $DBI::errstr\n";
+            print $App::DEBUG_FILE "EXPLAIN_SQL: $DBI::errstr\n";
             if ($rows) {
-                print 
"+----+-------------+----------------------+-------+----------------------+---------+----------+\n";
-                print "| id | select_type | table                | type  | key 
                 | key_len |     rows |\n";
-                print 
"+----+-------------+----------------------+-------+----------------------+---------+----------+\n";
+                print $App::DEBUG_FILE 
"+----+-------------+----------------------+-------+----------------------+---------+----------+\n";
+                print $App::DEBUG_FILE "| id | select_type | table             
   | type  | key                  | key_len |     rows |\n";
+                print $App::DEBUG_FILE 
"+----+-------------+----------------------+-------+----------------------+---------+----------+\n";
                 foreach my $row (@$rows) {
                     $key = $row->[5];
                     $keylen = length($key);
                     if ($keylen > 21) {
                        $key = substr($key,0,12) . ".." . 
substr($key,$keylen-7,7);
                     }
-                    printf("|%3s | %-12s| %-21s| %-6s| %-21s|%8d |%9d | %s\n", 
@{$row}[0,1,2,3], $key, @{$row}[6,8]);
+                    printf($App::DEBUG_FILE "|%3s | %-12s| %-21s| %-6s| 
%-21s|%8d |%9d | %s\n", @{$row}[0,1,2,3], $key, @{$row}[6,8]);
                 }
-                print 
"+----+----------------------------------------------------------------------------------------+\n";
-                print "| id | possible_keys/ref/extra\n";
-                print 
"+----+----------------------------------------------------------------------------------------+\n";
+                print $App::DEBUG_FILE 
"+----+----------------------------------------------------------------------------------------+\n";
+                print $App::DEBUG_FILE "| id | possible_keys/ref/extra\n";
+                print $App::DEBUG_FILE 
"+----+----------------------------------------------------------------------------------------+\n";
                 foreach my $row (@$rows) {
                     $key = $row->[5];
                     $posskeys = $row->[4];
                     $posskeys =~ s/\b($key)\b/[$key]/;
-                    printf("|%3s | posskeys: %s\n", $row->[0], $posskeys);
-                    printf("|%3s | ref:      %s; extra: %s\n", @{$row}[0,7,9]);
+                    printf($App::DEBUG_FILE "|%3s | posskeys: %s\n", 
$row->[0], $posskeys);
+                    printf($App::DEBUG_FILE "|%3s | ref:      %s; extra: 
%s\n", @{$row}[0,7,9]);
                 }
-                print 
"+---------------------------------------------------------------------------------------------+\n";
+                print $App::DEBUG_FILE 
"+---------------------------------------------------------------------------------------------+\n";
             }
         }
         else {
             $sql =~ /^\s*(\S*)/;
-            print "EXPLAIN_SQL: Can't explain $1 statement.\n";
+            print $App::DEBUG_FILE "EXPLAIN_SQL: Can't explain $1 
statement.\n";
         }
     }
 }

Reply via email to