You are here

protected function DbDumpCommand::getTableData in Drupal 8

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Command/DbDumpCommand.php \Drupal\Core\Command\DbDumpCommand::getTableData()

Gets all data from a given table.

If a table is set to be schema only, and empty array is returned.

Parameters

\Drupal\Core\Database\Connection $connection: The database connection to use.

string $table: The table to query.

Return value

array The data from the table as an array.

1 call to DbDumpCommand::getTableData()
DbDumpCommand::generateScript in core/lib/Drupal/Core/Command/DbDumpCommand.php
Generates the database script.

File

core/lib/Drupal/Core/Command/DbDumpCommand.php, line 295

Class

DbDumpCommand
Provides a command to dump the current database to a script.

Namespace

Drupal\Core\Command

Code

protected function getTableData(Connection $connection, $table) {
  $order = $this
    ->getFieldOrder($connection, $table);
  $query = $connection
    ->query("SELECT * FROM {" . $table . "} " . $order);
  $results = [];
  while (($row = $query
    ->fetchAssoc()) !== FALSE) {
    $results[] = $row;
  }
  return $results;
}