shop.balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

setting.php (849B)


      1 <?php
      2 class ModelSettingSetting extends Model {
      3 	public function getSetting($code, $store_id = 0) {
      4 		$data = array();
      5 
      6 		$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "setting WHERE store_id = '" . (int)$store_id . "' AND `code` = '" . $this->db->escape($code) . "'");
      7 
      8 		foreach ($query->rows as $result) {
      9 			if (!$result['serialized']) {
     10 				$data[$result['key']] = $result['value'];
     11 			} else {
     12 				$data[$result['key']] = json_decode($result['value'], true);
     13 			}
     14 		}
     15 
     16 		return $data;
     17 	}
     18 	
     19 	public function getSettingValue($key, $store_id = 0) {
     20 		$query = $this->db->query("SELECT value FROM " . DB_PREFIX . "setting WHERE store_id = '" . (int)$store_id . "' AND `key` = '" . $this->db->escape($key) . "'");
     21 
     22 		if ($query->num_rows) {
     23 			return $query->row['value'];
     24 		} else {
     25 			return null;	
     26 		}
     27 	}	
     28 }