Welcome Guest, Not a member yet? Register   Sign In
Profiler.php bolding queries patch
#1

[eluser]kirrie[/eluser]
Code:
Index: Profiler.php
===================================================================
--- Profiler.php    (revision 1)
+++ Profiler.php    (working copy)
@@ -132,7 +132,7 @@
         // Key words we want bolded
-        $highlight = array('SELECT', 'DISTINCT', 'FROM', 'WHERE', 'AND', 'LEFT JOIN', 'ORDER BY', 'GROUP BY', 'LIMIT', 'INSERT', 'INTO', 'VALUES', 'UPDATE', 'OR', 'HAVING', 'OFFSET', 'NOT IN', 'IN', 'LIKE', 'NOT LIKE', 'COUNT', 'MAX', 'MIN', 'ON', 'AS', 'AVG', 'SUM', '(', ')');
+        $highlight = array('SELECT', 'DISTINCT', 'FROM', 'WHERE', 'AND', 'LEFT JOIN', 'ORDER BY', 'GROUP BY', 'LIMIT', 'INSERT', 'INTO', 'VALUES', 'UPDATE', 'OR', 'HAVING', 'OFFSET', 'NOT IN', 'IN', 'JOIN', 'LIKE', 'NOT LIKE', 'COUNT', 'MAX', 'MIN', 'ON', 'AS', 'AVG', 'SUM', '\(', '\)');
            
@@ -158,7 +158,7 @@
    
                     foreach ($highlight as $bold)
                     {
-                        $val = str_replace($bold, '<strong>'.$bold.'</strong>', $val);    
+                        $val = preg_replace("/\b(".$bold.")\b/", "<strong>$1</strong>", $val);
                     }

"JOIN" keyword has no bold because of it looks like conflicting with "IN" keyword.
#2

[eluser]Unknown[/eluser]
THANKS FOR SHARING IT
#3

[eluser]John_Betong[/eluser]
[quote author="kirrie" date="1228447297"]
Code:
Index: Profiler.php
===================================================================
--- Profiler.php    (revision 1)
+++ Profiler.php    (working copy)
@@ -132,7 +132,7 @@
         // Key words we want bolded
-        $highlight = array('SELECT', 'DISTINCT', 'FROM', 'WHERE', 'AND', 'LEFT&nbsp;JOIN', 'ORDER&nbsp;BY', 'GROUP&nbsp;BY', 'LIMIT', 'INSERT', 'INTO', 'VALUES', 'UPDATE', 'OR', 'HAVING', 'OFFSET', 'NOT&nbsp;IN', 'IN', 'LIKE', 'NOT&nbsp;LIKE', 'COUNT', 'MAX', 'MIN', 'ON', 'AS', 'AVG', 'SUM', '(', ')');
+        $highlight = array('SELECT', 'DISTINCT', 'FROM', 'WHERE', 'AND', 'LEFT&nbsp;JOIN', 'ORDER&nbsp;BY', 'GROUP&nbsp;BY', 'LIMIT', 'INSERT', 'INTO', 'VALUES', 'UPDATE', 'OR', 'HAVING', 'OFFSET', 'NOT&nbsp;IN', 'IN', 'JOIN', 'LIKE', 'NOT&nbsp;LIKE', 'COUNT', 'MAX', 'MIN', 'ON', 'AS', 'AVG', 'SUM', '\(', '\)');
            
@@ -158,7 +158,7 @@
    
                     foreach ($highlight as $bold)
                     {
-                        $val = str_replace($bold, '<strong>'.$bold.'</strong>', $val);    
+                        $val = preg_replace("/\b(".$bold.")\b/", "<strong>$1</strong>", $val);
                     }

"JOIN" keyword has no bold because of it looks like conflicting with "IN" keyword.[/quote]
&nbsp;
&nbsp;
&nbsp;
BUMP
&nbsp;
&nbsp;
I have tried this code in the SVN Revision: 1721 and it works fine. Is it possible to include this revision?
&nbsp;
I did find another bug which occurs when the Profile is activated. The "&lt;/body&gt;&lt;/html>" did not get moved to the end of the Profiler output and results in umpteen HTML/CSS warnings.
&nbsp;
My quick KLUDGE for this is NOT to display "&lt;/body&gt;&lt;/html>" if the Profiler is activated.
&nbsp;
When the profiler is activated then it automatically appends the "&lt;/body&gt;&lt;/html>" to the end of the output.
&nbsp;
In case it makes any difference I am using Windows XP, WAMP and PHP Version 5.30.
&nbsp;
&nbsp;
&nbsp;
&nbsp;




Theme © iAndrew 2016 - Forum software by © MyBB