Система регионов
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
class ModelLocalisationZone extends Model {
|
||||
public function addZone($data) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "zone SET status = '" . (int)$data['status'] . "', name = '" . $this->db->escape($data['name']) . "', code = '" . $this->db->escape($data['code']) . "', country_id = '" . (int)$data['country_id'] . "'");
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "zone SET status = '" . (int)$data['status'] . "', name = '" . $this->db->escape($data['name']) . "', code = '" . $this->db->escape($data['code']) . "', slug = '" . $this->db->escape($data['slug']) . "', country_id = '" . (int)$data['country_id'] . "'");
|
||||
|
||||
$this->cache->delete('zone');
|
||||
|
||||
@@ -9,7 +9,7 @@ class ModelLocalisationZone extends Model {
|
||||
}
|
||||
|
||||
public function editZone($zone_id, $data) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "zone SET status = '" . (int)$data['status'] . "', name = '" . $this->db->escape($data['name']) . "', code = '" . $this->db->escape($data['code']) . "', country_id = '" . (int)$data['country_id'] . "' WHERE zone_id = '" . (int)$zone_id . "'");
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "zone SET status = '" . (int)$data['status'] . "', name = '" . $this->db->escape($data['name']) . "', code = '" . $this->db->escape($data['code']) . "', slug = '" . $this->db->escape($data['slug']) . "', country_id = '" . (int)$data['country_id'] . "' WHERE zone_id = '" . (int)$zone_id . "'");
|
||||
|
||||
$this->cache->delete('zone');
|
||||
}
|
||||
@@ -32,7 +32,8 @@ class ModelLocalisationZone extends Model {
|
||||
$sort_data = array(
|
||||
'c.name',
|
||||
'z.name',
|
||||
'z.code'
|
||||
'z.code',
|
||||
'z.slug'
|
||||
);
|
||||
|
||||
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
|
||||
@@ -89,4 +90,10 @@ class ModelLocalisationZone extends Model {
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
}
|
||||
|
||||
public function getTotalZonesBySlug($slug, $zone_id = 0) {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "zone WHERE slug = '" . $this->db->escape($slug) . "' AND zone_id != '" . (int)$zone_id . "'");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user