PHP code example of ccmbenchmark / bigquery-bundle
1. Go to this page and download the library: Download ccmbenchmark/bigquery-bundle 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/ */
ccmbenchmark / bigquery-bundle example snippets
class MyMetadata implements CCMBenchmark\BigQueryBundle\BigQuery\MetadataInterface {
public function getEntityClass(): string {
return MyEntity::class;
}
public function getDatasetId(): string {
return 'mydataset';
}
public function getProjectId(): string {
return 'myproject';
}
public function getTableId(): string {
return 'mytable';
}
public function getSchema(): array {
return [
[ "mode"=> "NULLABLE", "name"=> "sessions", "type"=> "INTEGER" ]
];
}
}
class MyEntity implements CCMBenchmark\BigQueryBundle\BigQuery\Entity\RowInterface {
use CCMBenchmark\BigQueryBundle\BigQuery\Entity\RowTrait;
private $sessions;
public function __construct(int $sessions) {
$this->sessions = $sessions;
}
public function jsonSerialize()
{
return [
'sessions' => $this->sessions,
'created_at' => (new \Datetime())->format('Y-m-d H:i:s'),
];
}
}
// @var $unitOfWork \CCMBenchmark\BigQueryBundle\BigQuery\UnitOfWork
$unitOfWork->addData(
new MyEntity(
1000
)
);
// Your data will be uploaded when calling this method
$unitOfWork->flush();