Ads

Counting Your SQL Querys

Have you ever wondered how on certain message boards, at the bottom beside the copyright it says XX Querys.

Isn't that neat, and also it is very simple to do as well. First thing is that your website or whatever you want to use the code on, needs to be using SESSIONS, if you search through our website, there is some very simple tutorials on it.

Now anyways, heres your full code.


CODE
function mysql_query_2($query){
$_SESSION['queries']++;
return mysql_query($query);
}



BREAKDOWN TIME:

First off, you need to use this function around any query.
example: $query = mysql_query_2(\"SELECT * FROM `table`\");
There is no need to use mysql_query(); since it is already done for you in your function


CODE
$_SESSION['queries']++;


This above takes all the querys within the session and adds them up.


CODE
return mysql_query($query);


This just returns the ($query) back to the server and does mysql_query on it.

Simple as PIE, that is II Image Not Found

Monday July 23, 2007 - 264 reads