vForums Support Banner



 

Welcome Guest! Please Login or Register
vForums Support :: Programming & Coding :: Programming Discussion :: I'll try this again... How to get the total quries - View Topic
Topic Rating: *****
Printable View
Dylan
Junior Member
**

[Avatar]

Posts: 136
Status: Offline
Gender: Male
Joined:  
Reputation: 0%  


pmwwwmsnaimxfire
I'll try this again... How to get the total quries (20th Jan 08 at 2:06am UTC)
Ok since cr0w just had to mess up my thread {Sad} i'll just try again...

so I just want to count all the php/mysql queries on my own php scripts. {Wink} I'm wondering how Ross did it.



And this it to wrightys reply in my old thread.

I wasn't asking on here, I'm almost positive you can't count the total queries with any client side script. This is for my own php and mysql project {Smile}

At cr0w's reply.

I did post in the programming board didn't I ?






Image
Michael
Moderator
*****

[Avatar]
Recoding the future

Posts: 4,043
Status: Offline
Gender: Male
Location: UK
Joined:  

Additional Groups:
Coding Team
***


Reputation: 58%  


pmtwittervForum
Re: I'll try this again... How to get the total .. (20th Jan 08 at 2:16am UTC)
ahh ok...

by you saying that proves cr0w was right.. {Tongue Out}




I would say... run a query and when the query is ran a value is incremented by one... then when you have ran all of the queries you simply output that number... {Unsure}

Cr0w or Ross can correct me if that is an epic phail! {Tongue Out} Try that though! {Cheesy}
Marc
vChat Developer
*****
I <3 Rossy

Posts: 3,388
Status: Offline
Gender: Male
Location: Ontario, Canada
Age: 32
Joined:  

Additional Groups:
Coding Team
***


Reputation: 40%  


pmwww
Re: I'll try this again... How to get the total .. (20th Jan 08 at 3:13am UTC)
Yeah Wrighty, that was pretty close. {Smile}

I usually do this:

Code:
 
  1. //Top of page
  2. $queries = 0;
  3. $start = microtime();
  4. function query($s){
  5.     $queries++;
  6.     return mysql_query($s);
  7. }
  8.  
  9. /* Page Content Here */
  10.  
  11. //Bottom of page
  12. $end = microtime();
  13. echo 'Page generated in '.$end-$start.' seconds, with '.$queries.' queries.';
 

rroll.to— Shorten a link, rickroll your friends.
Dylan
Junior Member
**

[Avatar]

Posts: 136
Status: Offline
Gender: Male
Joined:  
Reputation: 0%  


pmwwwmsnaimxfire
Re: I'll try this again... How to get the total .. (20th Jan 08 at 4:29am UTC)
i don't understand your query function crow?


Image
Ross
Administrator
*****

[Avatar]

Posts: 3,709
Status: Offline
Gender: Male
Age: 9 14
Joined:  

Additional Groups:
Support Team
***


Reputation: 45%  


pmwwwtwittergtalkvForum
Re: I'll try this again... How to get the total .. (20th Jan 08 at 11:33am UTC)
 
i don't understand your query function crow?


The way Cr0w said is very similar to what I use except my query function is a little more advanced since it does error logging, replaces special values in the query string and can return the query result. But the basic idea of it is so you would call

$myquery = query("SELECT * FROM table_name WHERE field='value' LIMIT 1");

Which would then use the query() function to increase the # of queries used as well as running the actual query.

Image
Marc
vChat Developer
*****
I <3 Rossy

Posts: 3,388
Status: Offline
Gender: Male
Location: Ontario, Canada
Age: 32
Joined:  

Additional Groups:
Coding Team
***


Reputation: 40%  


pmwww
Re: I'll try this again... How to get the total .. (20th Jan 08 at 3:07pm UTC)
 
 
i don't understand your query function crow?


The way Cr0w said is very similar to what I use except my query function is a little more advanced since it does error logging, replaces special values in the query string and can return the query result. But the basic idea of it is so you would call

$myquery = query("SELECT * FROM table_name WHERE field='value' LIMIT 1");

Which would then use the query() function to increase the # of queries used as well as running the actual query.


I do almost the same thing, Ross. {Smile} I update my query log & error log, as well as return an array [optional].

Usually something like this:
Code:
 
  1. function query($s,$a="false"){
  2.  
  3.     //Update # Queries
  4.     $queries++;
  5.  
  6.     //Query Log
  7.     error_log("Query: ".$s." @ ".date(),3,"query_log.txt");
  8.  
  9.     //Run Query
  10.     $query = mysql_query($s) or die(error_log("Query Error: ".mysql_error()." @ ".date(),3,"error_log.txt");
  11.  
  12.     //Create Array
  13.     if($a=="assoc"){
  14.         $query = mysql_fetch_assoc($query);
  15.     }
  16.     else if($a=="array"){
  17.         $query = mysql_fetch_array($query);
  18.     }
  19.     else if($a=="numrows"){
  20.         $query = mysql_num_rows($query);
  21.     }
  22.  
  23.     //Return Query
  24.     return $query;
  25. }
 


I was just showing Dylan how to show then number of queries, as well as the time to load the page. {Wink}

rroll.to— Shorten a link, rickroll your friends.
 Printable View

All times are GMT+0 :: The current time is 10:48am
Page generated in 0.6133 seconds
This Forum is Powered By vForums (v2.4)
Create a Forum for Free | Find Forums