You are here

top_searches.install in Top Searches 7

Same filename and directory in other branches
  1. 5 top_searches.install
  2. 6 top_searches.install

File

top_searches.install
View source
<?php

// $Id: top_searches.install,v 1.1.4.2 2009/11/05 10:13:33 zstolar Exp $
function top_searches_install() {

  // Create tables.

  //drupal_install_schema('top_searches');
  variable_set('top_searches_show_counters', 0);
  variable_set('top_searches_block_items', 50);
  drupal_set_message(t('Top searches module installed successfully.'));
}

//D7:
function top_searches_uninstall() {

  // Remove tables.
  switch (db_driver()) {

    //($GLOBALS['db_type']) D7: db_type replaced by function db_driver{
    case 'mysql':
    case 'mysqli':
      db_delete('variable')
        ->condition('name', 'top_searches%', 'like')
        ->execute();
      cache_clear_all('variables', 'cache');
      break;
  }
}
function top_searches_schema() {
  $schema['top_searches'] = array(
    'fields' => array(
      'qid' => array(
        'type' => 'serial',
        'length' => 11,
        'not null' => TRUE,
        'unsigned' => TRUE,
      ),
      'q' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'counter' => array(
        'type' => 'int',
        'length' => 11,
        'not null' => FALSE,
        'default' => 0,
        'unsigned' => TRUE,
      ),
    ),
    'unique keys' => array(
      'q' => array(
        'q',
      ),
    ),
    'primary key' => array(
      'qid',
    ),
  );
  return $schema;
}