function DbDumpTest::getTableSchema
Same name in other branches
- 9 core/tests/Drupal/KernelTests/Core/Command/DbDumpTest.php \Drupal\KernelTests\Core\Command\DbDumpTest::getTableSchema()
- 8.9.x core/tests/Drupal/KernelTests/Core/Command/DbDumpTest.php \Drupal\KernelTests\Core\Command\DbDumpTest::getTableSchema()
- 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: The table name.
Return value
array Array keyed by field name, with the values being the field type.
1 call to DbDumpTest::getTableSchema()
- DbDumpTest::testScriptLoad in core/
modules/ mysql/ tests/ src/ Kernel/ mysql/ DbDumpTest.php - Tests loading the script back into the database.
File
-
core/
modules/ mysql/ tests/ src/ Kernel/ mysql/ DbDumpTest.php, line 226
Class
- DbDumpTest
- Tests for the database dump commands.
Namespace
Drupal\Tests\mysql\Kernel\mysqlCode
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.