OpenCart 🇺🇦

Класс ModelLocalisationCountry extends Model { ... }

Тип Возвр. Описание
public mixed addCountry ( $data )
Исходный код метода:
$this->db->query("INSERT INTO " . DB_PREFIX . "country SET name = '" . $this->db->escape($data['name']) . "', iso_code_2 = '" . $this->db->escape($data['iso_code_2']) . "', iso_code_3 = '" . $this->db->escape($data['iso_code_3']) . "', address_format = '" . $this->db->escape($data['address_format']) . "', postcode_required = '" . (int)$data['postcode_required'] . "', status = '" . (int)$data['status'] . "'");

$this->cache->delete('country');
public mixed editCountry ( $country_id, $data )
Исходный код метода:
$this->db->query("UPDATE " . DB_PREFIX . "country SET name = '" . $this->db->escape($data['name']) . "', iso_code_2 = '" . $this->db->escape($data['iso_code_2']) . "', iso_code_3 = '" . $this->db->escape($data['iso_code_3']) . "', address_format = '" . $this->db->escape($data['address_format']) . "', postcode_required = '" . (int)$data['postcode_required'] . "', status = '" . (int)$data['status'] . "' WHERE country_id = '" . (int)$country_id . "'");

$this->cache->delete('country');
public void deleteCountry ( int $country_id )
Исходный код метода:
$this->db->query("DELETE FROM " . DB_PREFIX . "country WHERE country_id = '" . (int)$country_id . "'");

$this->cache->delete('country');
public array getCountry ( int $country_id )
Исходный код метода:
$query = $this->db->query("SELECT DISTINCT * FROM " . DB_PREFIX . "country WHERE country_id = '" . (int)$country_id . "'");

return $query->row;
public mixed getCountries ( $data = array() )
Исходный код метода:
if ($data) {
	$sql = "SELECT * FROM " . DB_PREFIX . "country";

	$sort_data = array(
		'name',
		'iso_code_2',
		'iso_code_3'
	);	

	if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
		$sql .= " ORDER BY " . $data['sort'];	
	} else {
		$sql .= " ORDER BY name";	
	}

	if (isset($data['order']) && ($data['order'] == 'DESC')) {
		$sql .= " DESC";
	} else {
		$sql .= " ASC";
	}

	if (isset($data['start']) || isset($data['limit'])) {
		if ($data['start'] < 0) {
			$data['start'] = 0;
		}					

		if ($data['limit'] < 1) {
			$data['limit'] = 20;
		}	

		$sql .= " LIMIT " . (int)$data['start'] . "," . (int)$data['limit'];
	}		

	$query = $this->db->query($sql);

	return $query->rows;
} else {
	$country_data = $this->cache->get('country');

	if (!$country_data) {
		$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "country ORDER BY name ASC");

		$country_data = $query->rows;

		$this->cache->set('country', $country_data);
	}

	return $country_data;			
}	
public int getTotalCountries ( )
Исходный код метода:
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "country");

return $query->row['total'];

Связанные классы:

Название класса Роль
class Cache { ... } Компонент Cache используется в данном классе
class DB { ... } Компонент Db используется в данном классе

Комментарии