AsyncMysqlQueryResult::endTime

Description

public function endTime(): float

The end time when the successful query began, in seconds since epoch.

Return Values

  • float - the end time as float seconds since epoch.

Examples

Every successful query has a result. And one of the methods on an AsyncMysqlQueryResult is endTime(), which tells you the time when we finally got our result.

Note that

  elapsedMicros() ~== endTime() - startTime()
<?hh

namespace Hack\UserDocumentation\API\Examples\AsyncMysql\QueryResult\EndTime;

use \Hack\UserDocumentation\API\Examples\AsyncMysql\ConnectionInfo as CI;

async function connect(\AsyncMysqlConnectionPool $pool):
  Awaitable<\AsyncMysqlConnection> {
  return await $pool->connect(
    CI::$host,
    CI::$port,
    CI::$db,
    CI::$user,
    CI::$passwd
  );
}
async function simple_query(): Awaitable<int> {
  $pool = new \AsyncMysqlConnectionPool(array());
  $conn = await connect($pool);
  $result = await $conn->query('SELECT name FROM test_table WHERE userID = 1');
  // What time was it when we finally got this result?
  var_dump($result->endTime());
  $conn->close();
  return $result->numRows();
}

function run(): void {
  $r = \HH\Asio\join(simple_query());
  var_dump($r);
}

run();
Output
float(1447364892.4679)
int(1)