简体   繁体   中英

php tree recursion using mySQL

I have the following code, and a huge ERROR : Maximum function nesting level of '100' reached, aborting!:

function getTree($id)
{
    $arr = array();
    $sql ='select * from arboree where parent_id=' . $id;
    $result = mysql_query($sql);
    while ($row = mysql_fetch_array($result)) {
        $arr[] = array(
            "Parinte" => $row["parent_id"],
            "Nod" => getTree($row["id"])
        );
    }
    return $arr;
}

getTree(1);

help please!!

As far as I know PHP itself doesn't limit recursion depth. If you are using the XDebug extension, you'll need to either increase the limit ( xdebug.max_nesting_level = 100 ) in php.ini or use a non-recursive solution.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM