时间:2021-07-01 10:21:17 帮助过:6人阅读
//类里面的递归函数
function test($id,$num=0,$max=200){
$sql="SELECT * FROM {{test}} WHERE id=$id";
$res=Yii::app()->db->createCommand($sql)->queryRow();
$num+=$res['value'];
if($num<$max){
$name=self::test($res['pid'],$num);
}else{
$name=$res['name'];
}
return $name;
}
//调用
$tr=new classtest();
echo $tr->test(7);
//结果 d