So I found this great function that converts mysql queries into a XML page, and it looks like exactly what I need. The only problem is that it uses mysql, but thats not sup
There are many ways to do it, I guess the most similar would be:
$fieldName = mysqli_fetch_field_direct($result, $i)->name;
http://www.php.net/manual/en/mysqli-result.fetch-field-direct.php