You are here

search_log.install in Search Log 7

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

Install file for Search log.

File

search_log.install
View source
<?php

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

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

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

/**
 * Implements hook_uninstall().
 */
function search_log_uninstall() {
  db_delete('variable')
    ->condition('name', 'search_log_%', 'LIKE')
    ->execute();
  cache_clear_all('variables', 'cache');
  drupal_set_message(t('Search log table and variables removed.'));
}

Functions