PHP code example of valdiney / google-bigquery-service
1. Go to this page and download the library: Download valdiney/google-bigquery-service library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
valdiney / google-bigquery-service example snippets
# 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);
# 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]);
# 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>";
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.