 
      
    MySQL
- 1 ответ
- 0 вопросов
    0
    Вклад в тег
    
      
      
    
  
  
 
  
  /*
 * make a tree array based on sql query
 */
function buildtree()
{
    $refs = array();
    $list = array();
    $nodes = (Получить поля guid и parent_guid из всей таблички);
    foreach ($nodes as $data) {
        $thisref = &$refs[$data['guid']];
        $thisref['parent_guid'] = $data['parent_guid'];
        if ($data['parent_guid'] == null) {
            $list[$data['guid']] = &$thisref;
        } else {
            $refs[$data['parent_guid']]['children'][$data['guid']] = &$thisref;
        }
    }
    return $list;
}