Categories
PHP

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 😉