where(["companyNo"=>$companyNo,"cat_id"=>$cat_id])->value($field,0); if($rate==0){ $parent = $this->name("cat")->where(["id"=>$cat_id])->value("pid",0); if($parent>0)$rate=$this->GetRate($companyNo,$parent,$field); } return $rate; } public function GetAllRate($companyNo,$cat_id){ $rate=$this->where(['companyNo'=>$companyNo,'cat_id'=>$cat_id])->findOrEmpty(); if($rate->isEmpty()){ $parent = $this->name('cat')->where(['id'=>$cat_id])->value('pid',0); if($parent>0)$rate=$this->GetAllRate($companyNo,$parent); } return $rate; } }