从查询结果中获取列名

Get column name from a query result

是否可以从查询中获取列名,例如:

SELECT name AS EmployeeName FROM wh.employee

是否可以在 return 结果中获取 EmployeeName。我目前的PHP码:

$result = $this->bigQueryService->jobs->getQueryResults($this->projectId, $jobId)
$rows = $result->getRows();
if ($rows) {
    foreach ($rows as $row) {
         /** @var \Google_Service_Bigquery_TableCell $cell */
         foreach ($row["f"] as $cell) {
             print $cell->getV();
         }
    }  
}

基本上,我想从查询结果中获取 EmployeeName,这可能吗?

我现在正在玩 Go,所以我非常简化的例子是 Go:

fields := resp.Schema.Fields
for i :=0 ; i < len(fields); i++ {
  field := fields[i].Name
  fmt.Println(field)
}

查看schema of the result了解更多详情

我不是PHP人,但我觉得应该是

$fields = $result->getSchema()->getFields();
$fieldNames = array();
foreach ($fields as $field) {
    $fieldNames[] = $field['name'];
}