class bigquery_base_table_service extends bigquery_base_service

Constants

DATASET

TABLE

IDNUMBER

TYPE_BOOL

TYPE_BOOLEAN

TYPE_INT64

TYPE_INTEGER

TYPE_FLOAT64

TYPE_FLOAT

TYPE_NUMERIC

TYPE_BIGNUMERIC

TYPE_STRING

TYPE_BYTES

TYPE_DATE

TYPE_DATETIME

TYPE_TIME

TYPE_TIMESTAMP

TYPE_ARRAY

TYPE_STRUCT

TYPE_RECORD

TYPE_GEOGRAPHY

TYPE_JSON

MODE_NULLABLE

MODE_REQUIRED

MODE_REPEATED

Properties

protected string $table from  bigquery_base_service
protected string $name from  bigquery_base_service
static protected $idnumber
static protected array $instances

Methods

string
get_name()

Retrieves and returns the localized name of the plugin.

static string
get_dataset()

Retrieves the dataset name associated with the class.

string
get_table()

Retrieves the table name associated with the object.

string
get_idnumber()

Retrieves the ID number associated with the object.

bool|string
primarykey()

Indicates whether the current instance has a primary key defined.

bool
foreignkeys()

Indicates whether foreign keys are present or enabled.

array
get_header()

Retrieves the header information associated with the current table.

array
get_fields()

Retrieves and returns the fields associated with the current table.

static bool
can_execute()

Determines if the current operation can be executed.

array
get_options()

Retrieves and constructs a set of options including schema, primary key, and foreign key information.

void
set_count_table_row()

Updates and stores the row count of a specific database table in the configuration.

bool|null
execute()

Executes the data preparation process for Google BigQuery, including table validation, data generation, and job creation, while handling errors and cleaning up temporary files.

static array
get_header_by_table(string $tablename)

Retrieves and returns the header of a table as an array of column names.

static array
get_fields_by_table(string $tablename)

Retrieves and returns the fields and their metadata for a given database table.

static string
get_field_type(string $type)

Determines and returns the corresponding field type based on the provided type.

array
get_schema()

Retrieves the schema of the current context.

array
generate_data()

Generates and retrieves data from the database table associated with this instance.

static string|null
save_to_csv(array $data, array $header)

Saves the provided data to a CSV file with an optional header.

static string
save_to_json(array $data)

Saves the provided data to a JSON file.

static string
get_filename(string $extension)

Generates a filename based on the class name, current timestamp, and given extension.

static string
get_filepath(string $extension)

Retrieves the full file path for a given file extension.

__construct(string $table = '', string $name = '', string $idnumber = '')

Constructor method to initialize the object with table, name, and idnumber.

getInstance(string $table, string|null $name = null, string|null $idnumber = null)

Get an instance of the class for a specific table.

Details

string get_name()

Retrieves and returns the localized name of the plugin.

Return Value

string

the localized plugin name string

at line 61
static string get_dataset()

Retrieves the dataset name associated with the class.

Return Value

string

the dataset name defined as a constant in the class

string get_table()

Retrieves the table name associated with the object.

If the table name is not set or is empty, it returns a default static table name.

Return Value

string

the table name, or a default static table name if not set

string get_idnumber()

Retrieves the ID number associated with the object.

If the ID number is not set, it returns a default static ID number.

Return Value

string

the ID number, or a default static ID number if not set

bool|string primarykey()

Indicates whether the current instance has a primary key defined.

Return Value

bool|string

returns false as the default indication of no primary key

bool foreignkeys()

Indicates whether foreign keys are present or enabled.

Return Value

bool

returns false, indicating that foreign keys are not present or enabled

array get_header()

Retrieves the header information associated with the current table.

Return Value

array

the header data obtained based on the table

at line 71
array get_fields()

Retrieves and returns the fields associated with the current table.

Return Value

array

the list of fields for the table returned by the get_table method

static bool can_execute()

Determines if the current operation can be executed.

Return Value

bool

returns true if the operation is permitted to execute, otherwise false

array get_options()

Retrieves and constructs a set of options including schema, primary key, and foreign key information.

Return Value

array

an associative array containing the schema and table constraints (primary key and foreign keys, if available)

void set_count_table_row()

Updates and stores the row count of a specific database table in the configuration.

This method retrieves the row count of a given table from the database and saves it into a configuration entry. If there are existing table row counts stored, they are maintained and updated with the new row count for the specific table.

Return Value

void

Exceptions

dml_exception

bool|null execute()

Executes the data preparation process for Google BigQuery, including table validation, data generation, and job creation, while handling errors and cleaning up temporary files.

Return Value

bool|null

returns true if the operation is successfully executed, otherwise false in case of an exception

static array get_header_by_table(string $tablename)

Retrieves and returns the header of a table as an array of column names.

Parameters

string $tablename

the name of the database table to fetch the header from

Return Value

array

an array of column names representing the header of the specified table

static array get_fields_by_table(string $tablename)

Retrieves and returns the fields and their metadata for a given database table.

Parameters

string $tablename

the name of the database table to fetch fields from

Return Value

array

an array of fields, where each field is represented by an associative array containing 'name' (field name), 'type' (field type), and optionally 'mode' if the field is required

static string get_field_type(string $type)

Determines and returns the corresponding field type based on the provided type.

Parameters

string $type

The type of the field as a string (e.g., 'bigint', 'tinyint').

Return Value

string

The corresponding field type constant (e.g., TYPE_INT64, TYPE_INTEGER, or TYPE_STRING).

protected array get_schema()

Retrieves the schema of the current context.

Return Value

array

protected array generate_data()

Generates and retrieves data from the database table associated with this instance.

Return Value

array

the data retrieved from the database table

Exceptions

dml_exception

static protected string|null save_to_csv(array $data, array $header)

Saves the provided data to a CSV file with an optional header.

Parameters

array $data

the data to be saved, each entry representing a row

array $header

an optional header row for the CSV file

Return Value

string|null

the file path of the saved CSV file

Exceptions

Exception

static protected string save_to_json(array $data)

Saves the provided data to a JSON file.

Each array entry will be written as a separate JSON object in a new line, following the newline-delimited JSON (NDJSON) format, often used for compatibility with tools like Google BigQuery.

Parameters

array $data

the array of data to be saved, where each element represents a row

Return Value

string

the full path to the saved JSON file

Exceptions

Exception

static protected string get_filename(string $extension)

Generates a filename based on the class name, current timestamp, and given extension.

Parameters

string $extension

the file extension to be used in the generated filename

Return Value

string

the generated filename

static protected string get_filepath(string $extension)

Retrieves the full file path for a given file extension.

Parameters

string $extension

the file extension for which the file path is generated

Return Value

string

the complete file path including the directory and filename

at line 33
__construct(string $table = '', string $name = '', string $idnumber = '')

Constructor method to initialize the object with table, name, and idnumber.

Parameters

string $table

the table name, defaults to an empty string

string $name

the name, defaults to an empty string

string $idnumber

the identifier number for the object

at line 47
static bigquery_base_table_service getInstance(string $table, string|null $name = null, string|null $idnumber = null)

Get an instance of the class for a specific table.

Parameters

string $table

the table name

string|null $name

the name, defaults to null

string|null $idnumber

the identifier number, defaults to null

Return Value

bigquery_base_table_service

an instance of the class for the specified table