protected function 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;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Command!DbDumpCommand.php/function/DbDumpCommand::getTableData/8.1.x