Query time result in MySQL w/ PHP

Is there a way that I can get the time of a MySQL query (specifically with PHP)? The actual time it took to complete the query, that is.

Something such as: Results 1 - 10 for brown. (0.11 seconds)

I tried to look for an example, to no avail. Here is an example of my code:

                    // prepare sql statement
                $stmt = $dbh->prepare("SELECT ijl, description, source, user_id, timestamp FROM Submissions WHERE MATCH (ijl, description) AGAINST (?)");

                // bind parameters
                $stmt->bindParam(1, $search, PDO::PARAM_STR);

                // execute prepared statement
                $stmt->execute();

For my current full text search using a MyISAM table engine. Any help would be incredible. Thank you.

This question and answers originated from www.stackoverflow.com
Question by (3/11/2011 1:04:00 AM)

Answer

$starttime = microtime(true);

//Do your query and stuff here

$endtime = microtime(true);
$duration = $endtime - $starttime

This will give you the run time in microseconds.

Answer by

Find More Answers
Related Topics  php  mysql  query  time  myisam
Related Questions
  • PHP/MySQL(i) use_result, store_result and MyISAM Table Locks

    I've read various sources (like this , this , or this one) about the difference between use_result() (unbuffered queries) and store_result() (buffered queries) and also know that MySQL keeps locks o…
  • Put result from mysql_query in php array

    I want to get some results from the MySQL database and put them in a array like this: array("value2", "value2", "value3"); I have tried this: $models = array(); $getmodels = mysql_query("s…
  • mysql query result in php variable

    Is there any way to store mysql result in php variable? thanks $query = "SELECT username,userid FROM user WHERE username = 'admin' "; $result=$conn->query($query); then I want to print sel…
  • looping MySQL query result in PHP

    $b = 1; $d = mysql_query("select *from 'table_name'"); while($b < 10){ while($e = mysql_fetch_array($d)){ echo $e['name_field']; } $b++; } I want to loop the output, but I'm stuck. …
  • Empty query result in php

    I'm having troubles with a PHP code. The problems come when I execute a SQL query with a PHP variable inside it. The result doesn't shows anything, and the field in the database is not empty. Tried …
  • PHP time() in 'if statements' not passed to MySql query?

    if($_SESSION['periode']){ if($_SESSION['periode'] == 'Today'){ $xdate = time() - (1 * 24 * 60 * 60); $ydate = time(); } if($_SESSION['periode'] == 'Yesterday'){ $xdate = time() - (2 * 2…
  • Query result in MySQL Console does not match the result of PHP's mysql_query()

    My MySQL query returns different results depending on how the query is submitted. When the query is submitted through the MySQL Console results in. mysql> SELECT `modx`.coverage_nation.id, …
  • mysql query execution time | reduce query

    I have a query which let me to change users order. here is my query: update test set orderID = case orderID when (select orderID from ( select * from test where orderID > ( select …
  • display multiple table as query result using ORDER BY in PHP MYSQL

    I need a help on these, where I want to display the query result with multiple table as the assets have different attributes, it will be ORDER BY category. Let's say, Category = Laptop will list all…
  • PHP MYSQL query result "RANKING"

    I need to get a list of users Ranking by points and from my command line (MySQL) is was able to generate the necessary code: SET @rank=0; SELECT rank, iduser, pontos FROM ( SELECT @rank:=@rank+1 …