【问题标题】:How to write a sql like query using PHP to get data from BigQuery如何使用 PHP 编写类似 sql 的查询以从 BigQuery 获取数据
【发布时间】:2016-11-07 11:02:07
【问题描述】:

谁能给我一个例子,可以使用当前客户端库通过 php 和 sql 类似的查询访问 BigQuery?

在新库中,凭据以 json 形式提供,与旧版本相比,其他更改很少,我不明白如何运行查询。所以如果有人能给我一个示例代码那就太好了

【问题讨论】:

  • Bigquery + PHP examples的可能重复
  • @Alex nope, $jobs->query($project_id, $query);因为在新库中,我认为我们不需要单独提供 project_id,因为凭据作为 json 传递
  • 您使用哪些客户端库?您是否尝试过编写任何代码,如果是,您能否分享它(以及它是如何失败的)?以下问题可能有助于解决您的身份验证问题:stackoverflow.com/questions/40396683/…

标签: php google-bigquery


【解决方案1】:
    $bigQuery = $this->getBigQuery();

    $tableName = $bigQuery->constructTableName('example');

    $query = $bigQuery->client->queryConfig("
        select distinct id from {$tableName}
    ");

    $queryJobConfig = $this->bigQuery->client->query($query);
    $this->$bigQuery->client->runQuery($queryJobConfig);

【讨论】:

  • 嗨,欢迎来到 SO,ty 贡献。您可以考虑制作tour,对于这个答案,可能会通过一些解释来改进它。也看看这里:How to Answer
猜你喜欢
  • 2021-12-07
  • 2019-05-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-09-08
  • 1970-01-01
  • 2014-12-23
  • 2016-06-07
相关资源
最近更新 更多