============
数据库查询:
$cates = DB::table(‘tp_article‘)->where(‘odds‘,‘=‘, $pid)->get();
public static function getCatesByDiGui($pid)
{
//获取分类
// return ‘sss‘;
$cates = DB::table(‘tp_article‘)->where(‘odds‘,‘=‘, $pid)->get();
//遍历分类信息
var_dump($cates);
exit;
// $cates = DB::table(‘tp_article‘)->where(‘odds‘,‘=‘, ‘$pid‘)->get();
$sub_cate = [];
foreach($cates as $k=>$v) {
$v->sub_cate = self::getCatesByDiGui($v->id);
$sub_cate[] = $v;
}
return $sub_cate;
}