.
public function BQ_Tables_Insert($client, $project_id, $dataset_id) {
$bq = new Google_Service_Bigquery($client);
$table_reference = new Google_Service_Bigquery_TableReference();
$table_reference->setProjectId($project_id);
$table_reference->setDatasetId($dataset_id);
$table_reference->setTableId(static::tableId());
$schema = new Google_Service_Bigquery_TableSchema();
$schema->setFields(static::fields());
$table = new Google_Service_Bigquery_Table();
$table->setTableReference($table_reference);
$table->setSchema($schema);
try {
return $bq->tables->insert($project_id, $dataset_id, $table);
} catch (Google_Service_Exception $e) {
$this->setErrors($e->getErrors())->setErrorMessage($e->getMessage());
throw $e;
}
}
static::tableId() - , static::fields() -
public static function fields() {
return array(
array('name' => 'user_id', 'type' => 'integer', 'mode' => 'required'),
array('name' => 'order_id', 'type' => 'integer', 'mode' => 'required'),
array('name' => 'status', 'type' => 'integer', 'mode' => 'nullable'),
array('name' => 'timestamp', 'type' => 'timestamp', 'mode' => 'nullable')
);
}