Show Number Of Queries In The Footer

free web hosting
Open Discussion > CONTRIBUTE > Computers > Programming Languages > PHP Programming

Show Number Of Queries In The Footer

Amezis
Hi, I need a script showing the number of queries done in the footer of my page.

If possible, I would also like a script showing how much time the queries took, and the time used to generate the page. But a script showing the number of queries is currently the most important smile.gif

Reply

Spectre
Uh, in relation to what? There isn't a single script that is going to be universally applicable to absolutely every possible situation. I would suggest you simply keep a record of how many queries are executed in the pre-processing of your page, and how long it took to execute them. It's not that difficult.

Reply

Amezis
Basically, this is what I want:
IPB Image

Reply

OpaQue
Create a class in the php file called DB for executing and doing all your database query related work.

And for every query you pass into it, it will execute it and at the same time, increment a counter variable.

You can use this variable for showing up the amount of queries executed.

Reply

Spectre
That's something along the lines of what I was thinking. Here is a very quick, untested, written purely for example demo:

CODE
<?php

class database {
   var $_query_count = 0;
   var $_conn_id = 0;
   var $_query_result = 0;
   var $_execution_time = 0;

   function database( $db_host, $db_user, $db_pass ) {
      $this->_conn_id = @mysql_pconnect($db_host,$db_user,$db_pass);
      if( !$this->_conn_id ) {
         return false;
      }
      return $this->_conn_id;
   }

   function sql_query( $query ) {
      $time_start = time() + microtime();
      $this->_query_result = @mysql_query($query);
      $time_end = time()+microtime();
      $this->_query_count++;
      $this->_execution_time += ($time_end-$time_start);
   }

   function close() {
      @mysql_free_result($this->_query_result);
      @mysql_close($this->_conn_id);
   }
}

?>


Usage could be something along the lines of:

CODE
$database = new database('host','user','pass');
$database->sql_query('SELECT X FROM Y');
echo '[ Time: ' . $database->_execution_time . ' ] [ Queries: ' . $database->_query_count . ' ]';
$database->close();


As I said earlier, however, this is not a 'universal' solution. You are going to have to do some coding of your own to integrate it into whatever environment you wish for it to exist. Hope it helps all the same.

Oh, and feel free to use that code as you wish.

 

 

 


Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.

Similar Topics

Keywords : queries footer

  1. Too Many Mysql Queries? - is it bad? (1)
  2. Editing Footer.php - adding a script (2)
    hey can somebody put this script into my footer.php file? because i don't know how. the script
    has to go between the and ok this is the script... CODE <!-- Clicksor.com Advertising
    Code Begin --> <script type='text/javascript'> <!--
    clicksor_layer_border_color = '#B4D0DC'; clicksor_layer_ad_bg = '#ECF8FF';
    clicksor_layer_ad_link_color = '#0000CC'; clicksor_layer_ad_text_color = '#000000';
    clicksor_text_link_bg = ''; clicksor_text_link_color = '#000FFF';
    clicksor_enable_pop = fa...
  3. Show Sql Queries From Other Site - (6)
    How do I use the sql database from other site? like showing the stats of certain field. Lets say
    I'm on a forum and wanted to show the number of post I have from a particular forum like trap17
    on my own site how do I do that?...



Looking for show, number, queries, footer

*RANDOM STUFF*





*SIMILAR VIDEOS*
Searching Video's for show, number, queries, footer

*MORE FROM TRAP17.COM*
advertisement



Show Number Of Queries In The Footer



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute your information that might help someone here.
Ask your Doubts & Queries to get answers.. "Together, We enlight each other!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE