function DbDumpTest::getTableSchema

Same name in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Command/DbDumpTest.php \Drupal\KernelTests\Core\Command\DbDumpTest::getTableSchema()
  2. 10 core/modules/mysql/tests/src/Kernel/mysql/DbDumpTest.php \Drupal\Tests\mysql\Kernel\mysql\DbDumpTest::getTableSchema()
  3. 11.x core/modules/mysql/tests/src/Kernel/mysql/DbDumpTest.php \Drupal\Tests\mysql\Kernel\mysql\DbDumpTest::getTableSchema()

Helper function to get a simplified schema for a given table.

Parameters

string $table:

Return value

array Array keyed by field name, with the values being the field type.

1 call to DbDumpTest::getTableSchema()
DbDumpTest::testScriptLoad in core/tests/Drupal/KernelTests/Core/Command/DbDumpTest.php
Test loading the script back into the database.

File

core/tests/Drupal/KernelTests/Core/Command/DbDumpTest.php, line 232

Class

DbDumpTest
Tests for the database dump commands.

Namespace

Drupal\KernelTests\Core\Command

Code

protected function getTableSchema($table) {
    // Verify the field type on the data column in the cache table.
    // @todo this is MySQL specific.
    $query = Database::getConnection()->query("SHOW COLUMNS FROM {" . $table . "}");
    $definition = [];
    while ($row = $query->fetchAssoc()) {
        $definition[$row['Field']] = $row['Type'];
    }
    return $definition;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.