You are here

function _countries_api_iso_get_country in Country codes API 5

Same name and namespace in other branches
  1. 6 countries_api.module \_countries_api_iso_get_country()

Function to return a country by code and name.

Parameters

$value: The country code value (in iso2,iso3,name, or printable name format)

$format: The format to return country by

Return value

array of country

4 calls to _countries_api_iso_get_country()
CountriesApiTest::test_invalidformat__countries_api_iso_get_country in tests/countries_api.test
Function to test invalid format passed to _countries_api_iso_get_country
CountriesApiTest::test_results_countries_api_iso_get_country in tests/countries_api.test
Function to test _countries_api_iso_get_country returns a value
countries_api_iso2_get_country in ./countries_api.module
ISO 3166-1-alpha-2 code to country API function
countries_api_iso3_get_country in ./countries_api.module
ISO 3166-1-alpha-3 code to country API function

File

./countries_api.module, line 176

Code

function _countries_api_iso_get_country($value, $format) {
  $value = trim(check_plain($value));
  $format = trim(check_plain($format));

  // Return false if format is invalid (saves a database hit!)
  if (!countries_api_validate_format($format)) {
    return false;
  }
  $result = db_query("SELECT iso2, name, printable_name, iso3, numcode FROM {countries_api_countries} WHERE %s = '%s'", $format, $value);
  return db_fetch_array($result);
}