Back to Opencart

File catalog\model\localisation\country.php

docs/api/source-catalog.model.localisation.country.html

4.1.0.36.8 KB
Original Source

Namespaces

Classes

| 1: | <?php | | 2: | namespace Opencart\Catalog\Model\Localisation; | | 3: | /** | | 4: | * Class Country | | 5: | * | | 6: | * @package Opencart\Catalog\Model\Localisation | | 7: | */ | | 8: | class Country extends \Opencart\System\Engine\Model { | | 9: | /** | | 10: | * Get Country | | 11: | * | | 12: | * @param int $country_id | | 13: | * | | 14: | * @return array<string, mixed> | | 15: | */ | | 16: | public function getCountry(int $country_id): array { | | 17: | $query = $this->db->query("SELECT *, c.name FROM " . DB\_PREFIX . "country c LEFT JOIN " . DB\_PREFIX . "address\_format af ON (c.address\_format\_id = af.address\_format\_id) WHERE c.country\_id = '" . (int)$country_id . "' AND c.status = '1'"); | | 18: | | | 19: | return $query->row; | | 20: | } | | 21: | | | 22: | /** | | 23: | * Get Country By Iso Code 2 | | 24: | * | | 25: | * @param string $iso_code_2 | | 26: | * | | 27: | * @return array<int, array<string, mixed>> | | 28: | */ | | 29: | public function getCountryByIsoCode2(string $iso_code_2): array { | | 30: | $sql = "SELECT * FROM " . DB\_PREFIX . "country WHERE iso\_code\_2 = '" . $this->db->escape($iso_code_2) . "' AND status = '1'"; | | 31: | | | 32: | $key = md5($sql); | | 33: | | | 34: | $country_data = $this->cache->get('country.' . $key); | | 35: | | | 36: | if (!$country_data) { | | 37: | $query = $this->db->query($sql); | | 38: | | | 39: | $country_data = $query->rows; | | 40: | | | 41: | $this->cache->set('country.' . $key, $country_data); | | 42: | } | | 43: | | | 44: | return $country_data; | | 45: | } | | 46: | | | 47: | /** | | 48: | * Get Country By Iso Code 3 | | 49: | * | | 50: | * @param string $iso_code_3 | | 51: | * | | 52: | * @return array<int, array<string, mixed>> | | 53: | */ | | 54: | public function getCountryByIsoCode3(string $iso_code_3): array { | | 55: | $sql = "SELECT * FROM " . DB\_PREFIX . "country WHERE iso\_code\_3 = '" . $this->db->escape($iso_code_3) . "' AND status = '1'"; | | 56: | | | 57: | $key = md5($sql); | | 58: | | | 59: | $country_data = $this->cache->get('country.' . $key); | | 60: | | | 61: | if (!$country_data) { | | 62: | $query = $this->db->query($sql); | | 63: | | | 64: | $country_data = $query->rows; | | 65: | | | 66: | $this->cache->set('country.' . md5($sql), $country_data); | | 67: | } | | 68: | | | 69: | return $country_data; | | 70: | } | | 71: | | | 72: | /** | | 73: | * Get Countries | | 74: | * | | 75: | * @return array<int, array<string, mixed>> | | 76: | */ | | 77: | public function getCountries(): array { | | 78: | $sql = "SELECT *, c.name FROM " . DB\_PREFIX . "country c LEFT JOIN " . DB\_PREFIX . "address\_format af ON (c.address\_format\_id = af.address\_format\_id) WHERE c.status = '1' ORDER BY c.name ASC"; | | 79: | | | 80: | $key = md5($sql); | | 81: | | | 82: | $country_data = $this->cache->get('country.' . $key); | | 83: | | | 84: | if (!$country_data) { | | 85: | $query = $this->db->query($sql); | | 86: | | | 87: | $country_data = $query->rows; | | 88: | | | 89: | $this->cache->set('country.' . $key, $country_data); | | 90: | } | | 91: | | | 92: | return $country_data; | | 93: | } | | 94: | } | | 95: | |

OpenCart API API documentation generated by ApiGen dev-master