MLM二叉树计数多级

时间:2018-05-22 06:36:23

标签: php laravel-4

function display_children($parent, $level) {
        $count = 0;
        $result = mysql_query('SELECT user_id FROM sponsers '.'WHERE parent_id="'.$parent.'"');
        while ($row = mysql_fetch_array($result))
        {
               $var = str_repeat(' ',$level).$row['user_id']."\n";

                       //echo $var  after remove comment check tree

                       // i call function in while loop until count all user_id 

               $count += 1 +$this->display_children($row['user_id'], $level+1);

        }
        return $count; // it will return all user_id count under parent_id
    } 

这是我的代码。我需要一些帮助,我将如何在laravel概念中实现,因为我在php概念中。

请帮帮我。有人能够使用laravel 4.2版本共享或修改代码

0 个答案:

没有答案