tp框架写了个方法获取顶级分类return结果就是null,在辅助函数都能打印出结果。 本帖最后由 xuzuning 于 2012-09-11 06:32:30 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 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; } } 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; } } 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; } } 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个查询语句是一样的吧。 诚聘网站PHP工程师,主要为网站B/S系统程序开发 aparche的设置问题 PHP如何生成JS,请高手帮助 php如果出现错误 执行其它代码 请教如何做? 初学函数,请教函数中常用的return WEB跟目录下有个PHP目录,为什么PHP目录里面的文件就访问不到?? 显示word文档的问题??? 怎么检验中文输入? 如何include根目录的文件 页面文字显示正常,对话框乱码!何解? 时间戳的问题和字符集编码的问题
$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;
}
}
$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;
}
}
$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;
}
}
$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个查询语句是一样的吧。