home | career | drupal | java | mac | mysql | perl | php | scala | uml | unix

Drupal example source code file (uc_payment_pack.install)

This example Drupal source code file (uc_payment_pack.install) is included in the DevDaily.com "Drupal Source Code Warehouse" project. The intent of this project is to help you "Learn Drupal by Example".

PHP - Drupal tags/keywords

array, database, default, description, int, not, null, order_id, ret, sql, the, true, unsigned

The uc_payment_pack.install Drupal example source code

<?php
// $Id: uc_payment_pack.install,v 1.2.2.7 2010/03/19 21:27:17 tr Exp $

/**
 * @file
 * Install hooks for uc_payment_pack.module.
 */

function uc_payment_pack_schema() {
  $schema = array();

  $schema['uc_payment_check'] = array(
    'description' => 'Stores check payment information.',
    'fields' => array(
      'check_id' => array(
        'description' => 'Primary key: the check ID.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'order_id' => array(
        'description' => 'The {uc_orders}.order_id.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'clear_date' => array(
        'description' => 'The Unix timestamp indicating the expected clear date for the check.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'indexes' => array(
      'order_id' => array('order_id'),
    ),
    'primary key' => array('check_id'),
  );

  $schema['uc_payment_cod'] = array(
    'description' => 'Stores COD payment information.',
    'fields' => array(
      'order_id' => array(
        'description' => 'The {uc_orders}.order_id.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'delivery_month' => array(
        'description' => 'The month of delivery. 1 => January, 2 => February, etc.',
        'type' => 'int',
        'size' => 'small',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'delivery_day' => array(
        'description' => 'The day of the month of delivery.',
        'type' => 'int',
        'size' => 'small',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'delivery_year' => array(
        'description' => 'The year of delivery.',
        'type' => 'int',
        'size' => 'small',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'primary key' => array('order_id'),
  );

  $schema['uc_payment_other'] = array(
    'description' => 'Stores Other payment type information.',
    'fields' => array(
      'order_id' => array(
        'description' => 'The {uc_orders}.order_id.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'description' => array(
        'description' => 'The description of the payment type.',
        'type' => 'varchar',
        'length' => 64,
        'not null' => TRUE,
        'default' => '',
      ),
    ),
    'primary key' => array('order_id'),
  );

  return $schema;
}

function uc_payment_pack_install() {
  drupal_install_schema('uc_payment_pack');
}

function uc_payment_pack_uninstall() {
  drupal_uninstall_schema('uc_payment_pack');

  db_query("DELETE FROM {variable} WHERE name LIKE 'uc_check_%%'");
  db_query("DELETE FROM {variable} WHERE name LIKE 'uc_cod_%%'");
}

function uc_payment_pack_update_6000() {
  $ret = array();

  db_drop_primary_key($ret, 'uc_payment_check');
  db_drop_index($ret, 'uc_payment_check', 'order_id');
  db_change_field($ret, 'uc_payment_check', 'check_id', 'check_id', array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE), array('primary key' => array('check_id')));
  db_change_field($ret, 'uc_payment_check', 'order_id', 'order_id', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0), array('indexes' => array('order_id' => array('order_id'))));

  db_drop_primary_key($ret, 'uc_payment_cod');
  db_change_field($ret, 'uc_payment_cod', 'order_id', 'order_id', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0), array('primary key' => array('order_id')));
  db_change_field($ret, 'uc_payment_cod', 'delivery_month', 'delivery_month', array('type' => 'int', 'unsigned' => TRUE, 'size' => 'small', 'not null' => TRUE, 'default' => 0));
  db_change_field($ret, 'uc_payment_cod', 'delivery_day', 'delivery_day', array('type' => 'int', 'unsigned' => TRUE, 'size' => 'small', 'not null' => TRUE, 'default' => 0));
  db_change_field($ret, 'uc_payment_cod', 'delivery_year', 'delivery_year', array('type' => 'int', 'unsigned' => TRUE, 'size' => 'small', 'not null' => TRUE, 'default' => 0));

  db_drop_primary_key($ret, 'uc_payment_other');
  db_change_field($ret, 'uc_payment_other', 'order_id', 'order_id', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0), array('primary key' => array('order_id')));

  return $ret;
}

Other Drupal examples (source code examples)

Here is a short list of links related to this Drupal uc_payment_pack.install source code file:

new blog posts

"Drupal" is a registered trademark of Dries Buytaert.

my drupal tutorials and examples  

Copyright 1998-2016 Alvin Alexander, alvinalexander.com
All Rights Reserved.

Beginning in 2016, a portion of the proceeds from pages under the '/drupal-code-examples/' URI will be donated to charity.