The problem is that most programmers including the better ones will always do recursive calls to the database, causing higher load on the DB.

You can do this in a single pass, using PHP References.

Example:

PHP Code: 
$refs = array();
$list = array(); //This is the baby

$result mysql_query("SELECT * FROM releases");

while(
$data = @mysql_fetch_assoc($result))
{
    
//Cfreate / Select a referenced variable in the memory
    
$thisref = &$refs$data['id'] ];

    
//Set the parent id
    
$thisref['parent'] = $data['parent'];

    
//Set the data as your going to need it later
    
$thisref['data'] = $data;

    
//If its not a root, set the referenced array
    
if ($data['parent'] == 0)
    {
        
$list$data['id'] ] = &$thisref;
    }
    else
    {
        
$refs$data['parent'] ]['children'][ $data['id'] ] = &$thisref;
    }

Example of why references works is like so:



The code above will replicate hierarchy in a PHP