Ok since cr0w just had to mess up my threadi'll just try again...
so I just want to count all the php/mysql queries on my own php scripts.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![]()
At cr0w's reply.
I did post in the programming board didn't I ?
ahh ok...
by you saying that proves cr0w was right..![]()
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...![]()
Cr0w or Ross can correct me if that is an epic phail!Try that though!
![]()
Yeah Wrighty, that was pretty close.![]()
I usually do this:
Code:
- //Top of page
- $queries = 0;
- $start = microtime();
- function query($s){
- $queries++;
- return mysql_query($s);
- }
- /* Page Content Here */
- //Bottom of page
- $end = microtime();
- echo 'Page generated in '.$end-$start.' seconds, with '.$queries.' queries.';
i don't understand your query function crow?
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 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.I update my query log & error log, as well as return an array [optional].
Usually something like this:Code:
- function query($s,$a="false"){
- //Update # Queries
- $queries++;
- //Query Log
- error_log("Query: ".$s." @ ".date(),3,"query_log.txt");
- //Run Query
- $query = mysql_query($s) or die(error_log("Query Error: ".mysql_error()." @ ".date(),3,"error_log.txt");
- //Create Array
- if($a=="assoc"){
- $query = mysql_fetch_assoc($query);
- }
- else if($a=="array"){
- $query = mysql_fetch_array($query);
- }
- else if($a=="numrows"){
- $query = mysql_num_rows($query);
- }
- //Return Query
- return $query;
- }
I was just showing Dylan how to show then number of queries, as well as the time to load the page.![]()