本帖最后由 xuzuning 于 2012-09-11 06:32:30 编辑

解决方案 »

  1.   

        function getFirst($id_category){     
              $cate_info=$this->category_obj->where('id_category='.$id_category)->find();   
              echo $this->category_obj->getLastSql().'<br/>';  
              if($cate_info['pid']!=0){
                   $this->getFirst($cate_info['pid']);//这里没有接住返回的数据               
              }else{
                   dump($cate_info);
                   return $cate_info;
              }          
         }
      

  2.   

    function getFirst($id_category){     
              $cate_info=$this->category_obj->where('id_category='.$id_category)->find();   
              echo $this->category_obj->getLastSql().'<br/>';  
              if($cate_info['pid']!=0){
                   $cate_info .=$this->getFirst($cate_info['pid']);               
              }else{
                   dump($cate_info);
                   return $cate_info;
              }          
         }
      

  3.   

    function getFirst($id_category){   
      $cate_info=$this->category_obj->where('id_category='.$id_category)->find();   
           echo $this->category_obj->getLastSql().'<br/>';   
      if($cate_info['pid']!=0){
           $cate_info =$this->getFirst($cate_info['pid']);   
      }else{
           dump($cate_info);
           return $cate_info;
      }   
      }
      

  4.   

    function getFirst($id_category){   
      $cate_info=$this->category_obj->where('id_category='.$id_category)->find();   
           echo $this->category_obj->getLastSql().'<br/>';   
      if($cate_info['pid']!=0){
           $cate_info =$this->getFirst($cate_info['pid']);   
      }
          return $cate_info;
        }
    另外我发现你2个查询语句是一样的吧。