function view_custom_table_update_8102 in Views Custom Table 8
Same name and namespace in other branches
- 9.0.x view_custom_table.install \view_custom_table_update_8102()
Take values from database and save to config file.
File
- ./
view_custom_table.install, line 28 - Installation functions for the View Custom Table module.
Code
function view_custom_table_update_8102() {
$connection = Database::getConnection();
$query = $connection
->select('custom_table_view_data')
->fields('custom_table_view_data');
$result = $query
->execute()
->fetchAll();
if (!empty($result)) {
$config = \Drupal::service('config.factory')
->getEditable('view_custom_table.tables');
foreach ($result as $row) {
$config
->set($row->table_name . '.table_name', $row->table_name);
$config
->set($row->table_name . '.table_database', $row->table_database);
$config
->set($row->table_name . '.description', $row->description);
$config
->set($row->table_name . '.column_relations', $row->column_relations);
$config
->set($row->table_name . '.created_by', $row->created_by);
}
$config
->save();
}
Database::getConnection()
->schema()
->dropTable('custom_table_view_data');
}