Returns a Vector representing all row blocks returned by the successful query

public function rowBlocks(): Vector<AsyncMysqlRowBlock>;

A row block can be the full result of the query (if there is only one row block), or it can be the partial result of the query (if there are more than one row block). The total number of row blocks makes up the entire result of the successful query.

Usually, there will be only one row block in the vector because the query completed in full in one attempt. However, if, for example, the query represented something that exceeded some network parameter, the result could come back in multiple blocks.



The following example shows how a call to AsyncMysqlQueryResult::rowBlocks gets you a Vector of AsyncMysqlRowBlock objects. Each object can then be queried for statistical data on that row, such as the number of fields that came back with the result, etc.

NOTE: A call to rowBlocks() actually pops the first element of that Vector. So, for example, if you have the following:

object(HH\Vector)#9 (1) {
  object(AsyncMysqlRowBlock)#10 (0) {

a call to rowBlocks() will make it so that you know have:

object(HH\Vector)#9 (0) {

and thus a subsequent call to rowBlocks() will return an empty Vector.

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

async function connect(
  \AsyncMysqlConnectionPool $pool,
): Awaitable<\AsyncMysqlConnection> {
  return await $pool->connect(
async function simple_query(): Awaitable<int> {
  $pool = new \AsyncMysqlConnectionPool(darray[]);
  $conn = await connect($pool);
  $result = await $conn->query('SELECT * FROM test_table WHERE userID < 50');
  // A call to $result->rowBlocks() actually pops the first element of the
  // row block Vector. So it mutates it.
  $row_blocks = $result->rowBlocks();
  if ($row_blocks->count() > 0) {
    // An AsyncMysqlRowBlock
    $row_block = $row_blocks[0];
    \var_dump($row_block->fieldName(2)); // string
  } else {
  return $result->numRows();

async function run(): Awaitable<void> {
  $r = await simple_query();
string(%d) "%s"
string(3) "age"
await \Hack\UserDocumentation\API\Examples\AsyncMysql\skipif_async();