You are here

function tb_megamenu_update_7101 in The Better Mega Menu 7

Add language field.

File

./tb_megamenu.install, line 40

Code

function tb_megamenu_update_7101(&$sandbox) {

  // remove existing primary key
  db_query("ALTER TABLE {tb_megamenus} DROP primary key");
  $field = array(
    'type' => 'varchar',
    'length' => 12,
    'not null' => TRUE,
    'default' => '',
  );
  $keys_new = array(
    'primary key' => array(
      'menu_name',
      'language',
    ),
  );
  db_add_field('tb_megamenus', 'language', $field, $keys_new);

  // set all existing menus to current language
  db_query("UPDATE {tb_megamenus} SET language = :language", array(
    ':language' => $GLOBALS['language']->language,
  ));
  return t('Added language field and set all existing menus to current language');
}