You are here

function view_custom_table_load_table_structure in Views Custom Table 8

Same name and namespace in other branches
  1. 9.0.x view_custom_table.module \view_custom_table_load_table_structure()

Function to get table structure information.

Parameters

null $table_name: Name of the table.

string $database: Name of database to connect to.

Return value

bool Return table info or FALSE.

1 call to view_custom_table_load_table_structure()
view_custom_table_views_data in ./view_custom_table.module
Implements hook_views_data().

File

./view_custom_table.module, line 232
view_custom_table.module

Code

function view_custom_table_load_table_structure($table_name = NULL, $database = 'default') {
  $connection = Database::getConnection('default', $database);
  if ($table_name != NULL) {
    $query = new FormattableMarkup('DESCRIBE @table_name', [
      '@table_name' => $table_name,
    ]);
    $result = $connection
      ->query($query);
    if ($result) {
      $table_info = $result
        ->fetchAll();
    }
  }
  else {
    return FALSE;
  }
  return isset($table_info) ? $table_info : FALSE;
}