On this page
function drupal_get_module_schema
drupal_get_module_schema($module, $table = NULL)
Returns a module's schema.
This function can be used to retrieve a schema specification in hook_schema(), so it allows you to derive your tables from existing specifications.
Parameters
string $module: The module to which the table belongs.
string $table: The name of the table. If not given, the module's complete schema is returned.
Related topics
- Schema API
- API to handle database schemas.
File
- core/includes/schema.inc, line 156
- Schema API handling functions.
Code
function drupal_get_module_schema($module, $table = NULL) {
// Load the .install file to get hook_schema.
module_load_install($module);
$schema = \Drupal::moduleHandler()->invoke($module, 'schema');
if (isset($table)) {
if (isset($schema[$table])) {
return $schema[$table];
}
return array();
}
elseif (!empty($schema)) {
return $schema;
}
return array();
}
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!includes!schema.inc/function/drupal_get_module_schema/8.1.x