You are here

protected function GdprDatabaseManager::getColumns in General Data Protection Regulation 3.0.x

Same name and namespace in other branches
  1. 8.2 modules/gdpr_dump/src/Service/GdprDatabaseManager.php \Drupal\gdpr_dump\Service\GdprDatabaseManager::getColumns()
  2. 8 modules/gdpr_dump/src/Service/GdprDatabaseManager.php \Drupal\gdpr_dump\Service\GdprDatabaseManager::getColumns()

Get the columns for a table.

Parameters

string $table: The table name.

Return value

\Drupal\Core\Database\StatementInterface|null An executed DB statement, or NULL.

Throws

\Drupal\Core\Database\InvalidQueryException

1 call to GdprDatabaseManager::getColumns()
GdprDatabaseManager::getTableColumns in modules/gdpr_dump/src/Service/GdprDatabaseManager.php
Fetch the tables with their columns.

File

modules/gdpr_dump/src/Service/GdprDatabaseManager.php, line 68

Class

GdprDatabaseManager
Class GdprDatabaseManager.

Namespace

Drupal\gdpr_dump\Service

Code

protected function getColumns($table) {

  // @todo How cross-driver is this?
  $query = $this->database
    ->select('information_schema.columns', 'columns');
  $query
    ->fields('columns', [
    'COLUMN_NAME',
    'DATA_TYPE',
    'COLUMN_COMMENT',
  ]);
  $query
    ->condition('TABLE_SCHEMA', $this->database
    ->getConnectionOptions()['database']);
  $query
    ->condition('TABLE_NAME', $table);
  return $query
    ->execute();
}