View source
<?php
function statistics_install() {
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
db_query("CREATE TABLE {accesslog} (\n aid int NOT NULL auto_increment,\n sid varchar(64) NOT NULL default '',\n title varchar(255) default NULL,\n path varchar(255) default NULL,\n url varchar(255) default NULL,\n hostname varchar(128) default NULL,\n uid int unsigned default '0',\n timer int unsigned NOT NULL default '0',\n timestamp int unsigned NOT NULL default '0',\n KEY accesslog_timestamp (timestamp),\n PRIMARY KEY (aid)\n ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
break;
case 'pgsql':
db_query("CREATE TABLE {accesslog} (\n aid serial,\n sid varchar(64) NOT NULL default '',\n title varchar(255) default NULL,\n path varchar(255) default NULL,\n url varchar(255) default NULL,\n hostname varchar(128) default NULL,\n uid int_unsigned default '0',\n timer int_unsigned NOT NULL default '0',\n timestamp int_unsigned NOT NULL default '0',\n PRIMARY KEY (aid)\n )");
db_query("CREATE INDEX {accesslog}_accesslog_timestamp_idx ON {accesslog} (timestamp)");
break;
}
}
function statistics_update_1000() {
$ret = array();
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
$ret[] = update_sql("ALTER TABLE {accesslog} CHANGE COLUMN sid sid varchar(64) NOT NULL default ''");
break;
case 'pgsql':
db_change_column($ret, 'accesslog', 'sid', 'sid', 'varchar(64)', array(
'not null' => TRUE,
'default' => "''",
));
break;
}
return $ret;
}
function statistics_uninstall() {
db_query('DROP TABLE {accesslog}');
variable_del('statistics_count_content_views');
variable_del('statistics_enable_access_log');
variable_del('statistics_flush_accesslog_timer');
variable_del('statistics_day_timestamp');
variable_del('statistics_block_top_day_num');
variable_del('statistics_block_top_all_num');
variable_del('statistics_block_top_last_num');
}