| 1 |
<?php |
<?php |
| 2 |
// $Id$ |
// $Id: countries_api.module,v 1.1.2.1 2009/03/18 04:12:49 ngmaloney Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* Implementation of hook_help() |
* Implementation of hook_help() |
| 232 |
} |
} |
| 233 |
|
|
| 234 |
/** |
/** |
| 235 |
* Function to import regions from CSV file |
* Function to import countries from CSV file |
| 236 |
* TODO: provide arguments for specifying csv files |
* TODO: provide arguments for specifying csv files |
| 237 |
* @param $offset |
* @param $offset |
| 238 |
* Int value for csv row offset. |
* Int value for csv row offset. |
| 239 |
* @return void |
* @return void |
| 240 |
**/ |
**/ |
| 241 |
function countries_api_csv_import_countries($offset = 1) { |
function countries_api_csv_import_countries($offset = 1) { |
| 242 |
//Prepopulate regions table |
//Prepopulate countries table |
| 243 |
$handle = fopen(dirname(__FILE__) .'/data/countries.csv', 'r'); |
$handle = fopen(dirname(__FILE__) .'/data/countries.csv', 'r'); |
| 244 |
$index = 1; |
$index = 1; |
| 245 |
while (($row = fgetcsv($handle, 1024, ',')) !== FALSE) { |
while (($row = fgetcsv($handle, 1024, ',')) !== FALSE) { |
| 273 |
} |
} |
| 274 |
|
|
| 275 |
/** |
/** |
| 276 |
* Function to flush (empty) the countries and regions database |
* Function to flush (empty) the countries database |
| 277 |
**/ |
**/ |
| 278 |
function _countries_api_flush() { |
function _countries_api_flush() { |
| 279 |
db_query("DELETE FROM {countries_api_countries}"); |
db_query("DELETE FROM {countries_api_countries}"); |
|
db_query("DELETE FROM {countries_api_regions}"); |
|
| 280 |
} |
} |