filters.class.php 1.08 KB
<?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);
	}
	
}
?>