Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. DbDumpCommand.php

function 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 305

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;
}
RSS feed
Powered by Drupal