Debug method suggestion

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I have built an application that generates much of its SQL on demand and 
I wanted to track the queries that were being generated.  At first I was 
writing the SQL to html comments that I could see using view source, but 
at least in Firefox view source seems to call the page again so I lose 
the specific SQL that generated the initial page.  So here's my solution:

Whenever I make a database call, the abstraction layer outputs the SQL 
inside a div like this:

echo "<div id=\"hidesql\" style=\"display:none;\">$query</div>";

Then I have two links on my page like these:

    <a href="javascript:(function(){var 
divs=document.getElementsByTagName('div'); 
for(i=0;i<divs.length;i++)if(divs[i].id=='hidesql') 
divs[i].style.display='';})();">Show SQL</a><br />
    <a href="javascript:(function(){var 
divs=document.getElementsByTagName('div'); 
for(i=0;i<divs.length;i++)if(divs[i].id=='hidesql') 
divs[i].style.display='none';})();">Hide SQL</a><br />

And I've also stored them as bookmarklets in case the page fails before 
those links render.

Now my SQL comments are invisible until I click the show link.  I've 
also put a couple of other debug comments inside those divs.

Enjoy.

-jmb



PHP Data object relational mapping generator
http://www.metastorage.net/ 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/php-objects/

<*> To unsubscribe from this group, send an email to:
    php-objects-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 




[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux