Sql query counter

Simple php script to be able to count how many SQL queries your script does.

$query_counter = 0;//counter for all the executed querys
	function app_query($query) {
	      global $query_counter;
	      $query_counter++;
	      return mysql_query( $query);//later this could be changed for another engine not only mysql
	}

To use it in your script instead of calling the function “mysql_query” , we will use ” app_query”.

To retrieve how many queries were done just:

echo $query_counter;

More simple impossible ;)

Related Posts
Help sharing and Flatter me ;)

One Comment

  1. [...] day we show how to count your Sql queries on PHP. Today we do 1 step more in your app to know how long does it takes to be executed in the server [...]

Leave a Reply

Follow me