annotate text/ad_text.install @ 7:6aeff3329e01 ad

maj module ad 2.1rc1
author piotre
date Mon, 20 Jul 2009 13:54:40 +0000
parents d8a3998dac8e
children
rev   line source
pierre@0 1 <?php
pierre@0 2 // $Id: ad_text.install,v 1.2.2.2.2.4.2.4 2009/02/16 17:06:50 jeremy Exp $
pierre@0 3
pierre@0 4 /**
pierre@0 5 * @file
pierre@0 6 * Ad_text module database schema.
pierre@0 7 *
pierre@0 8 * Copyright (c) 2005-2009.
pierre@0 9 * Jeremy Andrews <jeremy@tag1consulting.com>.
pierre@0 10 */
pierre@0 11
pierre@0 12 /**
pierre@0 13 * Implementation of hook_schema().
pierre@0 14 */
pierre@0 15 function ad_text_schema() {
pierre@0 16 $schema['ad_text'] = array(
pierre@0 17 'description' => 'The ad_text table stores sources of text ads.',
pierre@0 18 'fields' => array(
pierre@0 19 'aid' => array(
pierre@0 20 'type' => 'int',
pierre@0 21 'unsigned' => TRUE,
pierre@0 22 'not null' => TRUE,
pierre@0 23 'default' => 0,
pierre@0 24 ),
pierre@0 25 'url' => array(
pierre@0 26 'type' => 'varchar',
pierre@0 27 'length' => '255',
pierre@0 28 'not null' => TRUE,
pierre@0 29 'default' => '',
pierre@0 30 ),
pierre@0 31 'adheader' => array(
pierre@0 32 'type' => 'varchar',
pierre@0 33 'length' => '255',
pierre@0 34 'not null' => TRUE,
pierre@0 35 'default' => '',
pierre@0 36 ),
pierre@0 37 'adbody' => array(
pierre@0 38 'type' => 'text',
pierre@0 39 'not null' => FALSE,
pierre@0 40 ),
pierre@0 41 ),
pierre@0 42 'primary key' => array('aid'),
pierre@0 43 );
pierre@0 44
pierre@0 45 return $schema;
pierre@0 46 }
pierre@0 47
pierre@0 48 /**
pierre@0 49 * ad_text module installation.
pierre@0 50 */
pierre@0 51 function ad_text_install() {
pierre@0 52 drupal_install_schema('ad_text');
pierre@0 53 }
pierre@0 54
pierre@0 55 /**
pierre@0 56 * Allow complete uninstallation of the ad_text module.
pierre@0 57 */
pierre@0 58 function ad_text_uninstall() {
pierre@0 59 // Delete all ad_text content.
pierre@0 60 $result = db_query("SELECT aid FROM {ad_text}");
pierre@0 61 while ($aid = db_result($result)) {
pierre@0 62 node_delete($aid);
pierre@0 63 }
pierre@0 64
pierre@0 65 // Remove tables.
pierre@0 66 drupal_uninstall_schema('ad_text');
pierre@0 67 }