View Single Post
Old 01-30-2013, 07:12 AM   PM User | #2
jalex718
New to the CF scene

 
Join Date: Jan 2013
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
jalex718 is an unknown quantity at this point
I'd use something like this.

PHP Code:
<?php
//Usage
$dbC = new MysqlCounter();
$dbC->Query("SELECT * FROM `table");
echo 
$dbC->query_count." queries performed in ".$dbC->query_time." second(s)";


class 
MysqlCounter ()
{
    var 
$query_time 0;
    var 
$query_count 0;
    function 
query ($query$link_identifer false)
    {
        if(!
$link_identifer)
        {
            
$start_time microtime();
            
$result mysql_query($query);
            
$end_time microtime();
            
$query_time += ($end_time $start_time);
            
$query_count++;
        }
        else
        {
            
$start_time microtime();
            
$result mysql_query($query$link_identifer);
            
$end_time microtime();
            
$query_time += ($end_time $start_time);
            
$query_count++;    
        }
        return 
$result;
    }
}
?>
I also built in the feature to carry over the sql connection if needed.
jalex718 is offline   Reply With Quote