function forward_install in Forward 5
Same name and namespace in other branches
- 8.3 forward.install \forward_install()
- 8 forward.install \forward_install()
- 8.2 forward.install \forward_install()
- 6 forward.install \forward_install()
- 7.3 forward.install \forward_install()
- 7 forward.install \forward_install()
- 7.2 forward.install \forward_install()
- 4.x forward.install \forward_install()
- 4.0.x forward.install \forward_install()
File
- ./
forward.install, line 2
Code
function forward_install() {
drupal_set_message('Installing forward');
switch ($GLOBALS['db_type']) {
case 'mysqli':
case 'mysql':
$query1 = db_query("create table {forward_log} (\n path varchar(255) NOT NULL default '<front>',\n type varchar(8) NOT NULL default '',\n timestamp int(11) NOT NULL default '0',\n KEY (path)\n ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
$query2 = db_query("CREATE TABLE {forward_statistics} (\n nid int(10) unsigned NOT NULL,\n last_forward_timestamp int(11) NOT NULL default '0',\n forward_count int(10) unsigned NOT NULL default '0',\n clickthrough_count int(10) unsigned NOT NULL default '0',\n PRIMARY KEY (nid),\n KEY (last_forward_timestamp)\n );");
break;
case 'pgsql':
$query1 = db_query("CREATE TABLE {forward_log} (\n path varchar(255) NOT NULL default '<front>',\n type varchar(8) NOT NULL default '',\n timestamp integer NOT NULL default '0'\n )");
$query2 = db_query("CREATE TABLE {forward_statistics} (\n nid integer NOT NULL,\n last_forward_timestamp integer NOT NULL default '0',\n forward_count integer NOT NULL default '0',\n clickthrough_count integer NOT NULL default '0',\n PRIMARY KEY (nid)\n )");
db_query("CREATE INDEX idx_forward_log_path ON {forward_log} (path);");
db_query("CREATE INDEX {forward_statistics}_last_forward_timestamp_idx ON {forward_statistics} (last_forward_timestamp);");
break;
default:
break;
}
// End case
db_query("INSERT INTO {forward_statistics} (nid, last_forward_timestamp, forward_count, clickthrough_count) SELECT n.nid, 0, 0, 0 FROM {node} n");
if ($query1 && $query2) {
drupal_set_message(t('Forward module installed tables successfully.'));
}
else {
drupal_set_message(t('Table installation for the Forward module was unsuccessful. The tables may need to be installed by hand. See forward.install file for a list of the installation queries.'), 'error');
}
}