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

Drupal example source code file (china_156_1.cif)

This example Drupal source code file (china_156_1.cif) 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, db_query, foreach, function, insert, into, php, sql, values, zone, zone_name, zones

The china_156_1.cif Drupal example source code

<?php
// $Id: china_156_1.cif,v 1.1.4.6 2010/04/14 05:18:19 tr Exp $

/**
* First implement hook_install() using the name of the country as the base of
* the function name.
*/
function china_install() {
  // Make the entry in the country table.
  // VALUES = Country ID, Country Name, 2-digit Code, 3-digit Code, File Version
  db_query("INSERT INTO {uc_countries} (country_id, country_name, country_iso_code_2, country_iso_code_3, version) VALUES (156, 'China', 'CN', 'CHN', 1)");

  // Make the entries in the zones table.  Use %d for the zone_id and the
  // function uc_get_zone_ids($num) as the second argument for db_query() where
  // $num is the number of zones in the INSERT query.
  // VALUES = %d for ID, Parent Country ID, Zone Abbreviation, Zone Name
  $zones = array(
    array(156, '京', '北京'),
    array(156, '沪', '上海'),
    array(156, '津', '天津'),
    array(156, '渝', '重庆'),
    array(156, '冀', '河北'),
    array(156, '豫', '河南'),
    array(156, '鄂', '湖北'),
    array(156, '湘', '湖南'),
    array(156, '苏', '江苏'),
    array(156, '赣', '江西'),
    array(156, '辽', '辽宁'),
    array(156, '吉', '吉林'),
    array(156, '黑', '黑龙江'),
    array(156, '陕', '陕西'),
    array(156, '鲁', '山东'),
    array(156, '晋', '山西'),
    array(156, '川', '四川'),
    array(156, '青', '青海'),
    array(156, '皖', '安徽'),
    array(156, '琼', '海南'),
    array(156, '粤', '广东'),
    array(156, '桂', '广西'),
    array(156, '贵', '贵州'),
    array(156, '浙', '浙江'),
    array(156, '闽', '福建'),
    array(156, '甘', '甘肃'),
    array(156, '云', '云南'),
    array(156, '蒙', '内蒙古'),
    array(156, '宁', '宁夏'),
    array(156, '新', '新疆'),
    array(156, '藏', '西藏'),
    array(156, '港', '香港'),
    array(156, '澳', '澳门'),
    array(156, '台', '台湾'),
  );

  foreach ($zones as $zone) {
    db_query("INSERT INTO {uc_zones} (zone_country_id, zone_code, zone_name) VALUES (%d, '%s', '%s')", $zone);
  }

  uc_set_address_format(156,
    "!company\r\n!last_name !first_name\r\n!street1\r\n!street2\r\n"
    ."!city, !zone_name !postal_code\r\n!country_name_if");
}

Other Drupal examples (source code examples)

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