You are here

function flashnode_install in Flash Node 5.2

Same name and namespace in other branches
  1. 5.6 flashnode.install \flashnode_install()
  2. 5.3 flashnode.install \flashnode_install()
  3. 6.3 flashnode.install \flashnode_install()
  4. 6.2 flashnode.install \flashnode_install()

Implementation of hook_install().

flashnode used to be just flash, so we need to check if {flash} table already exists when we install flashnode. If it does then we need to rename it, otherwise we install the table as normal

File

./flashnode.install, line 10

Code

function flashnode_install() {
  if (db_table_exists('flash')) {

    // Migrating from an earlier version of flash
    _flashnode_migrate_from_flash();
  }
  else {

    // first install - create the table
    switch ($GLOBALS['db_type']) {
      case 'mysql':
      case 'mysqli':
        db_query('
          CREATE TABLE {flashnode} (
            nid INT(10) UNSIGNED NOT NULL ,
            height INT(10) UNSIGNED NOT NULL ,
            width INT(10) UNSIGNED NOT NULL ,
            display TINYINT(3) UNSIGNED NOT NULL ,
            substitution LONGTEXT NOT NULL,
            flashvars LONGTEXT NOT NULL,
            base VARCHAR(255) DEFAULT NULL,
            PRIMARY KEY (nid)
          ) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */;');
        break;
      case 'pgsql':
        db_query("\n          create table {flashnode} (\n            nid integer not null,\n            height integer not null,\n            width integer not null,\n            display integer not null,\n            substitution text not null default '',\n            flashvars text not null default '',\n            base VARCHAR(255) default NULL,\n            PRIMARY KEY (nid)\n          );");
        break;
    }
  }
  drupal_set_message(t('Flash node has been setup.'));
}