You are here

search_log.install in Search Log 6

Same filename and directory in other branches
  1. 8 search_log.install
  2. 7 search_log.install

Install file for Search log.

File

search_log.install
View source
<?php

/**
 * @file
 * Install file for Search log.
 */

/**
 * Implementation of hook_schema().
 */
function search_log_schema() {
  $schema['search_log'] = array(
    'description' => t('Log of search terms.'),
    'fields' => array(
      'qid' => array(
        'type' => 'serial',
        'not null' => TRUE,
        'description' => 'Primary Key: Auto-incrementing query ID.',
      ),
      'q' => array(
        'description' => t('Search term.'),
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'module' => array(
        'description' => t('Module implementing search.'),
        'type' => 'varchar',
        'length' => 64,
        'not null' => TRUE,
        'default' => '',
      ),
      'day' => array(
        'description' => t('Day search was performed.'),
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'counter' => array(
        'description' => t('Number of times search performed on day.'),
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'size' => 'medium',
      ),
      'result' => array(
        'description' => t('Indicator of failed or successful searches.'),
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'primary key' => array(
      'qid',
    ),
    'unique keys' => array(
      'qmd' => array(
        'q',
        'module',
        'day',
      ),
    ),
  );
  return $schema;
}

/**
 * Implementation of hook_install().
 */
function search_log_install() {
  drupal_install_schema('search_log');
  drupal_set_message(st('Search log table installed. !config', array(
    '!config' => l(st('Configure Search log'), 'admin/settings/search/search_log'),
  )));
}

/**
 * Implementation of hook_uninstall().
 */
function search_log_uninstall() {
  drupal_uninstall_schema('search_log');
  db_query("DELETE FROM {variable} WHERE name LIKE 'search_log_%'");
  cache_clear_all('variables', 'cache');
  drupal_set_message(t('Search log table and variables removed.'));
}

Functions

Namesort descending Description
search_log_install Implementation of hook_install().
search_log_schema Implementation of hook_schema().
search_log_uninstall Implementation of hook_uninstall().