Blame view

modules/default/model/filters.class.php 1.08 KB
8d65d0ce   andryeyev   init
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
  <?php
  Class Filters{
  	private $db;
  	private $lang;
  	
   
  	function __construct($lang){
  		$this->db = sdb::getInstance();
  		$this->lang = $lang;
  	}
  	
  	public function getBeginFilters(){
  		$sql = "select * from catalogs_filters where parent_id=? order by sort asc";
  		return $this->db->getAll($sql,array(0),DB_FETCHMODE_ASSOC);
  	}
  	
  	public function getListFilters($id){
  		$count = $this->db->getOne("select count(*) from catalogs_filters where parent_id=?", array($id));
  		$_id = ($count>0) ? $id : $this->getParentID($id);
  		$sql = "select * from catalogs_filters where parent_id=? order by sort asc";
  		return $this->db->getAll($sql,array($_id),DB_FETCHMODE_ASSOC);
  	}
  
  	private function getParentID($id){
  		return $this->db->getOne("select parent_id from catalogs_filters where id=?", array($id));
  	}
  	
  	public function getTranslit($filter_translit){
  		return $this->db->getOne("select id from catalogs_filters where translit=?",array($filter_translit));
  	}
  	
  	public function getFilter($id){
  		return $this->db->getRow("select * from catalogs_filters where id=?",array($id),DB_FETCHMODE_ASSOC);
  	}
  	
  }
  ?>