class Colum extends Model{
//无限分类查询
public function select_all(){
$data=$this->paginate(10);
return $this->select_type($data);
}
public function select_type($dat,$pid=0,$leave=0){
static $arr=array();
foreach ($dat as $key => $value) {
if($value['pid']==$pid){
$value['leave']=$leave;
$arr[]=$value;
$this->select_type($dat,$value['id'],$leave+2);
}
}
return $arr;
}
}
controller代码
public function index(){
//实例化model
$colunmo=new colunModel;
$data=$colunmo->select_all();
$this->assign('dat',$data);
return $this->fetch();
}
页面代码
{$dat->render()}
最佳答案