八零cms在thinkphp中获取父栏目及栏目路径方法

function selchann($cid){
	$pids = '';
    $parent_id =Db::query("select c_name,c_id, c_parentid from 80cms_column   where c_id=any(select c_parentid from 80cms_column  where c_id=".$cid.") limit 1");
    if(empty($parent_id)){
    	$pids="无";
    }
    foreach($parent_id as $k){
    	if($k['c_parentid']=='0'){
    		$pids=$k['c_name'];
    	}
    }
//  dump($parent_id);
    return $pids;

}
//获取路径
function lujing($cid){
	$pids = '';
	$data=Db::name('80cms_column')->field('c_path,c_parentid')->where(['c_id'=>$cid])->find();
    $pd=$data['c_parentid'];
    $pid=Db::name('80cms_column')->where(['c_id'=>$pd])->find();
    if($pid['c_parentid']=='0'){
    	$pid='/'.$pid['c_path'].'/'.$data['c_path'].'/';
 

你可能感兴趣的:(php,后端)