Gossamer Forum
Quote Reply
View SQL Query?
Is there any way to view the SQL query that has just been executed, without making the script DIE? I'm trying to see what query is being run, as part of the script. Any ideas are much appreciated :)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] View SQL Query? In reply to
Use debug=1

and check your logs.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] View SQL Query? In reply to
Is there no way to do it without using the logs, something like $table->sql or something? I was using my log files to start with, but it got a bit annoying downloading a 5Mb file everytime I wanted to see the query that was run Frown

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] View SQL Query? In reply to
Oooh... you mean I can teach you a trick?? <G>

Code:
#!/usr/local/bin/perl
# Error Log Script
# Copyright (c) 1998
#######################################################################

# Change the path to the path to your error log
$error_log = "/www/httpd/logs/error.log";

# Print out the header
print "Content-type: text/html\n\n";

#print out a useless set of HTML tags
print "<html><title>Server Errors</Title>\n";
print "<H3>Recent Server Errors</H3><HR>\n";

#open log and grab the last entries -- note the "double negative"
open (ELOG, "tail -50 $error_log | tail -50 |") || die $!;

while (<ELOG>) {
print; print "\n<HR>\n";
}

#cleanup
close (ELOG);
print "";
exit;


You may need to adjust a few things here or there depending on your system, but this has ported well over the years from one server to another, with only changing the log location.

I never got fancy, and put this script in each server that I'm working on, though you could put it in one location, and pass in a parameter for different logs.

Just open a new browser window, and keep an eye on what you are doing. :)

Oh, this program is made especially to be brain dead. It could be made fancier with an HTML interface to the various logs, templates and such, but why??? <g>


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] View SQL Query? In reply to
oooh... probably won't run under Windows, unless you add in a Unix-like package of utilities.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] View SQL Query? In reply to
LOL..just found a copy of this on my computer ina backup ZIP file....must have written it a while ago. Very similar to your code, but it just uses `` and the 'tail' command within that.

Thanks for the idea though Smile

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] View SQL Query? In reply to
You could just leave an ssh window open whilst you are coding and when you hit an error just do:

bash$ tail -10 /var/log/httpd/error_log

Last edited by:

Paul: Sep 25, 2002, 10:20 AM
Quote Reply
Re: [Andy] View SQL Query? In reply to
Yes, turn debug on and then do:

<pre><%GT::SQL::query_stack_disp%></pre>

in your template, and it will show you the last 20 sql queries executed.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] View SQL Query? In reply to
Cheers Alex, that was the answer I was looking for Smile

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!