function get_node_data($parent_category_id, $connection)
{
$query = "SELECT * FROM category WHERE parent_id = '$parent_category_id'";
$res = mysqli_query($connection, $query);
$output = array();
while ($row = mysqli_fetch_assoc($res)) {
$sub_array = array();
$sub_array['text'] = $row['title'];
$sub_array['type'] = $row['category_type'];
$sub_array['nodes'] = array_values(get_node_data($row['id'], $connection));
$output[] = $sub_array;
}
return $output;
}
Примерно так и думал сделать, как вы и предложили про cron.