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

Drupal example source code file (uc_credit.install)

This example Drupal source code file (uc_credit.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

change, database, function, math, max, not, null, php, ret, return, sql, uc_payment_credit, update_sql, varchar

The uc_credit.install Drupal example source code

<?php
// $Id: uc_credit.install,v 1.4.2.3 2008/11/07 21:13:23 islandusurper Exp $

/**
 * @file
 * Install file for the credit module... this is mostly legacy code now.
 */

function uc_credit_uninstall() {
  db_query("DELETE FROM {variable} WHERE name LIKE 'uc_credit_%%'");
}

function uc_credit_update_1() {
  $ret[] = update_sql("ALTER TABLE {uc_payment_credit} ADD cc_bank VARCHAR(255) NOT NULL, ADD cc_type VARCHAR(255) NOT NULL");

  $max = db_result(db_query("SELECT MAX(credit_id) FROM {uc_payment_credit}"));
  if (is_numeric($max)) {
    $ret[] = update_sql("INSERT INTO {sequences} VALUES ('{uc_payment_credit}_credit_id', ". $max .")");
  }

  return $ret;
}

function uc_credit_update_2() {
  $ret[] = update_sql("ALTER TABLE {uc_payment_credit} CHANGE `cc_owner` `cc_owner` VARCHAR(255) NOT NULL, "
                     ."CHANGE `cc_number` `cc_number` VARCHAR(255) NOT NULL, "
                     ."CHANGE `cc_exp_month` `cc_exp_month` VARCHAR(255) NOT NULL, "
                     ."CHANGE `cc_exp_year` `cc_exp_year` VARCHAR(255) NOT NULL, "
                     ."CHANGE `cc_cvv` `cc_cvv` VARCHAR(255) NOT NULL");

  return $ret;
}

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

  db_drop_table($ret, 'uc_payment_credit');

  return $ret;
}

Other Drupal examples (source code examples)

Here is a short list of links related to this Drupal uc_credit.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.