Lampwrights Forum > Other Stuff > vBulletin Talk
Register Community Today's Posts Search

Reply
 
Thread Tools
07-18-2012, 02:17 PM   #1
Jeff
Administrator
 
Jeff's Avatar
 
Join Date: Jul 2010
Posts: 402
Rep Power: 10
Jeff is getting browny points
Tracing MySQL Queries in Vbulletin

Sometimes you find the need to to trace back where queries are coming from, whether they be in your slow log, or if you are watching them real time. Sometimes it can be hard finding which script is firing certain queries. By editing includes/class_core.php, you can insert a MySQL comment at the end of all queries telling you what script was invoked when the call was made. Find this code:

PHP Code:
    function &execute_query($buffered true, &$link)
    {
        
$this->connection_recent =& $link;
        
$this->querycount++; 
Add this line afterwards:

PHP Code:
$this->sql .= ' #Executed from ' $this->escape_string(THIS_SCRIPT); 
Now when you view a query coming through the MySQL server, you will see something like:

Code:
SELECT * FROM thread where userid = 901324 #Executed from showthread
Jeff is offline   Reply With Quote

Reply

Tags

vbulletin code

,

vbulletin other



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT -4. The time now is 09:36 PM.


Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2024, vBulletin Solutions, Inc.