db = sdb::getInstance();
$this->lang = $lang;
}
public function getCatalogUL($url,$id = 0,$level = -1,&$menu = ''){
// global $menu;
$sql = "select * from catalogs_rubrics where parent_id=? and is_pic=0 and is_view=0";
if(self::$brend_id>0)$sql .= sprintf(" and brend_id='%d'",self::$brend_id);
$sql .= " order by sort asc";
$q=$this->db->query($sql,array($id));
if(!$q->numRows())
return;
$level++;
if($level == 0)$menu.= "
\n";
else $menu.= "\n";
while($q->fetchInto($arr,DB_FETCHMODE_ASSOC))
{
$menu.= '- ';
$menu.= '';
$menu.= $arr['name'];
$menu.= '';
if(in_array($arr['id'],$this->getTreeCatalog(self::$catalog_id))){//$this->getCatalogUL($url,$arr['id'],$level,$menu);
$p_res = $this->db->getAll("select * from catalogs_products where catalog_id=?",array($arr['id']),DB_FETCHMODE_ASSOC);
if(count($p_res)>0){
$menu.= '';
}
}
$menu.= "
\n";
}
$menu.= "
\n";
return $menu;
}
private function getTreeCatalog($id){
$ids = array();
while($id>0){
$row = $this->db->getRow('select id,parent_id from catalogs_rubrics where id=?',array($id),DB_FETCHMODE_ASSOC);
$ids[] = $row['id'];
$id = $row['parent_id'];
} //print_r($ids);
// sort($ids);
return $ids;
}
public function getRubricsIsPic(){
$sql = "select * from catalogs_rubrics where is_pic=?";
return $this->db->getAll($sql,array(1),DB_FETCHMODE_ASSOC);
}
public function getRubric($id){
return $this->db->getRow("select * from catalogs_rubrics where id=?",array($id),DB_FETCHMODE_ASSOC);
}
public function getTranslit($translit){
return $this->db->getOne("select id from catalogs_rubrics where translit=?",array($translit));
}
}
?>