Recursive function php with ibase querys

Viewed 103

I have a function that builds a path through the id of a certain file the function works perfectly until it throws an ibase_query error. Here is the function:

function Build_Path($id,$database){
$path_query = "SELECT PATH_NAME,FATHER_ID,VOLUME_ID FROM PATHS WHERE PATH_ID = ".$id;
$query = ibase_query($database, $path_query);
while ($names = ibase_fetch_object($query)) {
    $path_volume_id = $names->VOLUME_ID;
    $name = $names->PATH_NAME;
    $father_id = $names->FATHER_ID;
    if ($name == "") {
        $volumes = ibase_query($database, "SELECT VOLUME_NAME FROM VOLUMES WHERE VOLUME_ID = " . $path_volume_id);
        while ($get_volume_name = ibase_fetch_object($volumes)) {
            return $get_volume_name->VOLUME_NAME;
        }
        ibase_free_result($volumes);
    } else {
        return Build_Path($father_id, $database) . "/" . $name;
    }
}
ibase_free_result($query);
ibase_close($database);
}

The error is only thrown after the path number 12999 and it's says:

ibase_query(): too many open handles to database

The error is thrown once and then the query does not recieve any result although i have 1500000+ paths in my database.

1 Answers
Related