note 39702 deleted from function.mysql-query by irchtml
| From: | irchtml@php.net | Date: | Sun, 08 Feb 2004 07:30:54 +0000 |
| Subject: | note 39702 deleted from function.mysql-query by irchtml | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-64809@lists.php.net to get a copy of this message | ||
Note Submitter: nate AT adeptisoft DOT com
----
Calculate how long a query takes to run using mysql_query()...
<?php
function mysql_query_timed($sql) {
$time1 = microtime();
$resource_id = mysql_query($sql);
$time2 = microtime();
$time3 = $time2-$time1;
return array($resource_id,$time3);
}
$sql = "SELECT * FROM mytable";
$query = mysql_query_timed($sql);
echo "execution time:" . $query[1];
?>
If you need to use mysql_fetch_array() on your query use $query[0] instead of $query as you normally
would.
<?php
$fetch_rows = mysql_fetch_array($query[0]);
?>