DbDumpCommand::getTableData

protected DbDumpCommand::getTableData(Connection $connection, $table)

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.

File

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

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;
}
doc_Drupal
2016-10-29 09:01:09
Comments
Leave a Comment

Please login to continue.