/*
**获取id及该id下面的所有子id。
**
*/
private function cateArr($id){
//static $cateArrid=array();
$cateArrid[]=$id;
$cate_id=$id;
if($this->cateIsson($cate_id)){
$cateSonid=$this->cateGetsonid($cate_id);
foreach($cateSonid as $k=>$v){
$cateArrid=array_merge($cateArrid,$this->cateArr($v['id']));
}
}
return $cateArrid;
}
/*
**判断分类下面是否有子分类
**
*/
private function cateIsson($id){
$category_model=M('category');
$cate_id=$id;
$w['parent_id']=$cate_id;
$category_count=$category_model->where($w)->count();
return $category_count;
}
/*
**获取子分类id
**
*/
private function cateGetsonid($id){
$category_model=M('category');
$cate_id=$id;
$w['parent_id']=$cate_id;
$field="category.id";
$cateList=$category_model->field($field)->where($w)->select();
return $cateList;
}