valdiney/google-bigquery-service 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

valdiney/google-bigquery-service

Composer 安装命令:

composer require valdiney/google-bigquery-service

包简介

This Service is used to abstrain the use of the BigQuery from Google using php language.

README 文档

README

This Service is used to abstrain the use of the BigQuery from Google using php language

Dependencis

To use this Service you should first install the offial library from Google and our google-bigquery-service:

$ composer require google/cloud-bigquery
$ composer require valdiney/google-bigquery-service

Inicial usage

To start, you should firts create a dataset and a table:

require_once 'vendor/autoload.php';

# Instanciating the object to be used in the our application
# You should pass the path and name of your json file with yours credensials downloaded from google acount
$bigQuery = new GoogleBigQueryService\BigQueryService("AlarmaAe-b01ab0a3aa4c.json");

# Struturing the schema of the table. 
$schema = [
	[
	  "name" => "name",
	  "type" => "string"
	],
	[
	    "name" => "age",
	    "type" => "integer"
	]
];

# Creating the dataset and the table
$bigQuery->createSchema("datasetName", "tableName", $schema);

Insert data

after creating the dataset and the table, we ready to insert data:

require_once 'vendor/autoload.php';

# Instanciating the object to be used in the our application
$bigQuery = new GoogleBigQueryService\BigQueryService("AlarmaAe-b01ab0a3aa4c.json");

# The name of dataset
$bigQuery->setDatasetId("datasetName");

# The name of table
$bigQuery->setTable("tableName");

# Inserting data in our table. You shoul pass an associative array to the insert method
$bigQuery->insert(["name" => "Nicolas tesla", "age" => 87]);

Selecting data from our table

To select data is very simple. You just need pass your SQL query to the query method.
You need pass the especial string "{table} " between the SQL query. This especial string will be repleced into the class in a format that the BigQuery understand!:

require_once 'vendor/autoload.php';

# Instanciating the object to be used in the our application
$bigQuery = new GoogleBigQueryService\BigQueryService("AlarmaAe-b01ab0a3aa4c.json");

# The name of dataset
$bigQuery->setDatasetId("datasetName");

# The name of table
$bigQuery->setTable("tableName");

# Your SQL query
$collections = $bigQuery->query("SELECT * FROM {table}");

foreach ($collections as $data) {
    echo "Name: " .$data["name"] . "<br>";
    echo "Age:  " .$data["age"]  . "<br>";
}

统计信息

  • 总下载量: 3
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-08-16

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固