public function getChildren($parent, $level=0,$getlevel=array()) {
$criteria = new CDbCriteria;
$criteria->condition='referred_by_user_id=:id';
$criteria->params=array(':id'=>$parent);
$count = array(0=>0);
$model = $this->findAll($criteria);
// $levelcount = array();
$user=User::model()->findbypk(Yii::app()->user->id);
if($user->level!=$level)
{
foreach ($model as $key) {
$count[0]++;
$index=1;
// echo str_repeat(' — ', $level) . $key->name . "<br />";
$children= $this->getChildren($key->id, $level+1);
// pr($children);die;
foreach ($children as $child)
{
// pr($child);
if ($child==0)
continue;
if (isset($count[$index]))
$count[$index] += $child;
else
$count[$index] = $child;
$index++;
}
}
}
return $count;
}
我只能输出用户数。如何获取数组中每个级别的用户 ID?
千万里不及你
临摹微笑