Documentation

DataBQ
in package

[$bq = $this->core->loadClass('DataBQ');] Class to handle Bigquery datasets:tables with CloudFramework models

https://cloud.google.com/bigquery/docs/reference/libraries#client-libraries-install-php

Table of Contents

Properties

$_last_query  : mixed
$_last_query_time  : mixed
$_lastExecutionMicrotime  : mixed
$_only_create_query  : mixed
$_version  : mixed
$client  : BigQueryClient|null
$core  : mixed
$dataset  : Dataset
$dataset_name  : mixed
$debug  : mixed
$entity_schema  : mixed
$error  : mixed
$errorMsg  : mixed
$fields  : mixed
$key  : mixed
$limit  : mixed
$mapping  : mixed
$offset  : mixed
$options  : mixed
$order  : mixed
$page  : mixed
$project_id  : mixed
$table  : Table
$table_name  : mixed
$extraWhere  : mixed
$groupBy  : mixed
$joins  : mixed
$queryFields  : mixed
$queryWhere  : mixed
$use_mapping  : mixed
$view  : mixed
$virtualFields  : mixed

Methods

__construct()  : mixed
_insertWithStreamingBuffer()  : bool|null|void
Insert a record in dataset.table
addError()  : mixed
Add an error in the class
addOrder()  : mixed
Add Order into a query with a new field
addQueryWhere()  : mixed
Array with key=>value Especial values: '__null__' '__notnull__' '__empty__' '__notempty__'
addVirtualField()  : mixed
checkBigQueryStructure()  : array<string|int, mixed>
Return a structure with bigquery squema based on CF model
createDataSetTableInfo()  : array<string|int, mixed>|void
Return datasets associated to the project
dbFeed()  : array<string|int, mixed>|void
Feed a table in Bigquery
dbQuery()  : array<string|int, mixed>|void
Execute a Query with a title
delete()  : bool|null|void
Delete a record in db
fetch()  : array<string|int, mixed>|void
Return records [0..n][record_structure] from the db object
fetchByKeys()  : mixed
Return the tuplas with the $keyWhere including $fields
fetchOne()  : array<string|int, mixed>|void
Return [record_structure]
fetchOneByKey()  : mixed
Return one record based on a key
getBigQueryStructureFromModel()  : array<string|int, mixed>
Return a structure with bigquery squema based on CF model
getDataSetInfo()  : array<string|int, mixed>|void
Return datasets associated to the project
getDataSets()  : array<string|int, mixed>|void
Return datasets associated to the project
getDataSetTableInfo()  : array<string|int, mixed>|void
Return datasets associated to the project
getDataSetTables()  : array<string|int, mixed>|void
Return datasets associated to the project
getDBQuery()  : null|string
Return last query executed
getDBQueryTime()  : int|null
Return last time spent y last query
getExtraWhere()  : mixed
getFields()  : array<string|int, mixed>|null
Return the fields defined for the table in the schema
getFormModelWithMapData()  : mixed|null
Return the json form model to be used in validations in front-end
getInterfaceModelFromDatasetTable()  : array<string|int, mixed>
Return a structure with bigquery squema based on CF model
getMappingFields()  : array<string|int, mixed>
Return the mapped field namesdefined in the schema mapping
getQuerySQLFields()  : mixed
getQuerySQLFroms()  : mixed
getQuerySQLWhereAndParams()  : mixed
getSQLSelectFields()  : array<string|int, mixed>|null
Return the fields ready for a SQL query
getValidatedArrayFromData()  : array<string|int, mixed>
Return an array of the mapped fields ready to insert or update Validating the info
getValidatedRecordToInsert()  : mixed
insert()  : bool|null|void
Insert a record in db. If $upsert is true and the record exist then update it
insertWithStreamingBuffer()  : bool|null|void
Streaming Insert a record in db. It couldn't be deleted or updated before 30' after insertion
join()  : mixed
onlyCreateQuery()  : mixed
Define When I want to build a query but I do not want to be executed I call this method with true value
query()  : mixed
reset()  : mixed
Reset init values
setExtraWhere()  : mixed
setGroupBy()  : mixed
setLimit()  : mixed
Set a limit in the select query or fetch method.
setOffset()  : mixed
Set a offset in the select query or fetch method.
setOrder()  : mixed
Set Order into a query with a field
setPage()  : mixed
Set a page in the select query or fetch method.
setQueryFields()  : mixed
Defines the fields to return in a query. If empty it will return all of them
setQueryWhere()  : mixed
Array with key=>value Especial values: '__null__' '__notnull__' '__empty__' '__notempty__'
setView()  : mixed
setVirtualField()  : mixed
softDelete()  : bool|null|void
Update a record in db It requires to add always the following condition: and _created < TIMESTAMP_SUB(_created, INTERVAL 30 MINUTE) because you can not update or delete records inserted before 30' has passed
test()  : array<string|int, mixed>|void
Just a test query to know if the service works
unsetOrder()  : mixed
About Order
update()  : bool|null|void
Update a record in db It requires to add always the following condition: and _created < TIMESTAMP_SUB(_created, INTERVAL 30 MINUTE) because you can not update or delete records inserted before 30' has passed
upsert()  : bool|null|void
Upsert a record in db
useMapping()  : mixed
Active or deactive mapping of fields
_feed()  : bool|void
Feed a table with $data
_query()  : array<string|int, mixed>|void
Execute a query in BigQuery
processSchema()  : bool|void
Process Schema

Properties

$_last_query

public mixed $_last_query = \null

$_last_query_time

public mixed $_last_query_time = 0

$_lastExecutionMicrotime

public mixed $_lastExecutionMicrotime = 0

$_only_create_query

public mixed $_only_create_query = \false

$_version

public mixed $_version = '20230905'

$client

public BigQueryClient|null $client = \null

$core

public mixed $core = \null

$dataset

public Dataset $dataset = \null

$dataset_name

public mixed $dataset_name = \null

$debug

public mixed $debug = \false

$entity_schema

public mixed $entity_schema = \null

$error

public mixed $error = \false

$errorMsg

public mixed $errorMsg = []

$fields

public mixed $fields = []

$mapping

public mixed $mapping = []

$offset

public mixed $offset = 0

$options

public mixed $options = []

$project_id

public mixed $project_id = \null

$table

public Table $table = \null

$table_name

public mixed $table_name = \null

$extraWhere

private mixed $extraWhere = ''

$groupBy

private mixed $groupBy = ''

$joins

private mixed $joins = []

$queryFields

private mixed $queryFields = ''

$queryWhere

private mixed $queryWhere = []

$use_mapping

private mixed $use_mapping = \false

$view

private mixed $view = \null

$virtualFields

private mixed $virtualFields = []

Methods

__construct()

public __construct(Core7 &$core,  $params) : mixed
Parameters
$core : Core7
$params :

[0] = dataset_name [1] = cfo_schema [3] = $options = [projectId, KeyFile,..]

_insertWithStreamingBuffer()

Insert a record in dataset.table

public _insertWithStreamingBuffer( $data) : bool|null|void
Parameters
$data :
Return values
bool|null|void

addError()

Add an error in the class

public addError(mixed $value) : mixed
Parameters
$value : mixed

addOrder()

Add Order into a query with a new field

public addOrder( $field[,  $type = 'ASC' ]) : mixed
Parameters
$field :
$type : = 'ASC'

addQueryWhere()

Array with key=>value Especial values: '__null__' '__notnull__' '__empty__' '__notempty__'

public addQueryWhere(array<string|int, mixed> $keysWhere) : mixed
Parameters
$keysWhere : array<string|int, mixed>

addVirtualField()

public addVirtualField( $field,  $value) : mixed
Parameters
$field :

String virtual field name

$value :

String value or other field

checkBigQueryStructure()

Return a structure with bigquery squema based on CF model

public checkBigQueryStructure([mixed $fix = false ]) : array<string|int, mixed>
Parameters
$fix : mixed = false
Return values
array<string|int, mixed>

createDataSetTableInfo()

Return datasets associated to the project

public createDataSetTableInfo(array<string|int, mixed> $fields[, mixed $dataset_name = null ][, mixed $table_name = null ]) : array<string|int, mixed>|void
Parameters
$fields : array<string|int, mixed>
$dataset_name : mixed = null
$table_name : mixed = null
Return values
array<string|int, mixed>|void

dbFeed()

Feed a table in Bigquery

public dbFeed( $title,  $table_id,  &$data) : array<string|int, mixed>|void
Parameters
$title :
$table_id :
$data :
Return values
array<string|int, mixed>|void

dbQuery()

Execute a Query with a title

public dbQuery( $title,  $_q[, array<string|int, mixed> $params = [] ]) : array<string|int, mixed>|void
Parameters
$title :
$_q :
$params : array<string|int, mixed> = []
Return values
array<string|int, mixed>|void

delete()

Delete a record in db

public delete( $data) : bool|null|void
Parameters
$data :
Return values
bool|null|void

fetch()

Return records [0..n][record_structure] from the db object

public fetch([array<string|int, mixed>|string $keysWhere = [] ][, null $fields = null ][, mixed $groupBy = null ][, mixed $params = [] ]) : array<string|int, mixed>|void
Parameters
$keysWhere : array<string|int, mixed>|string = []
$fields : null = null
$groupBy : mixed = null
$params : mixed = []
Return values
array<string|int, mixed>|void

fetchByKeys()

Return the tuplas with the $keyWhere including $fields

public fetchByKeys( $keysWhere[, null $fields = null ]) : mixed
Parameters
$keysWhere :
$fields : null = null

if null $fields = $this->getFields()

fetchOne()

Return [record_structure]

public fetchOne([array<string|int, mixed> $keysWhere = [] ][, null $fields = null ][, mixed $groupBy = null ][, mixed $params = [] ]) : array<string|int, mixed>|void
Parameters
$keysWhere : array<string|int, mixed> = []
$fields : null = null
$groupBy : mixed = null
$params : mixed = []
Return values
array<string|int, mixed>|void

fetchOneByKey()

Return one record based on a key

public fetchOneByKey( $key[, null $fields = null ]) : mixed
Parameters
$key :

can ba an string or number

$fields : null = null

if null $fields = $this->getFields()

getBigQueryStructureFromModel()

Return a structure with bigquery squema based on CF model

public getBigQueryStructureFromModel() : array<string|int, mixed>
Return values
array<string|int, mixed>

getDataSetInfo()

Return datasets associated to the project

public getDataSetInfo([mixed $dataset_name = null ]) : array<string|int, mixed>|void
Parameters
$dataset_name : mixed = null
Return values
array<string|int, mixed>|void

getDataSets()

Return datasets associated to the project

public getDataSets() : array<string|int, mixed>|void
Return values
array<string|int, mixed>|void

getDataSetTableInfo()

Return datasets associated to the project

public getDataSetTableInfo([mixed $dataset_name = null ][, mixed $table_name = null ]) : array<string|int, mixed>|void
Parameters
$dataset_name : mixed = null
$table_name : mixed = null
Return values
array<string|int, mixed>|void

getDataSetTables()

Return datasets associated to the project

public getDataSetTables([mixed $dataset_name = null ]) : array<string|int, mixed>|void
Parameters
$dataset_name : mixed = null
Return values
array<string|int, mixed>|void

getDBQuery()

Return last query executed

public getDBQuery() : null|string
Return values
null|string

getDBQueryTime()

Return last time spent y last query

public getDBQueryTime() : int|null
Return values
int|null

getExtraWhere()

public getExtraWhere() : mixed

getFields()

Return the fields defined for the table in the schema

public getFields() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|null

getFormModelWithMapData()

Return the json form model to be used in validations in front-end

public getFormModelWithMapData() : mixed|null
Return values
mixed|null

getInterfaceModelFromDatasetTable()

Return a structure with bigquery squema based on CF model

public getInterfaceModelFromDatasetTable() : array<string|int, mixed>
Return values
array<string|int, mixed>

getMappingFields()

Return the mapped field namesdefined in the schema mapping

public getMappingFields() : array<string|int, mixed>
Return values
array<string|int, mixed>

getQuerySQLFields()

public getQuerySQLFields([mixed $fields = null ]) : mixed
Parameters
$fields : mixed = null

getQuerySQLFroms()

public getQuerySQLFroms() : mixed

getQuerySQLWhereAndParams()

public getQuerySQLWhereAndParams([mixed $keysWhere = [] ]) : mixed
Parameters
$keysWhere : mixed = []

getSQLSelectFields()

Return the fields ready for a SQL query

public getSQLSelectFields([mixed $fields = null ]) : array<string|int, mixed>|null
Parameters
$fields : mixed = null
Return values
array<string|int, mixed>|null

getValidatedArrayFromData()

Return an array of the mapped fields ready to insert or update Validating the info

public getValidatedArrayFromData( &$data[, mixed $all = true ][, array<string|int, mixed> &$dictionaries = [] ]) : array<string|int, mixed>
Parameters
$data :
$all : mixed = true
$dictionaries : array<string|int, mixed> = []
Return values
array<string|int, mixed>

getValidatedRecordToInsert()

public getValidatedRecordToInsert(mixed &$data) : mixed
Parameters
$data : mixed

insert()

Insert a record in db. If $upsert is true and the record exist then update it

public insert( $data[, bool $upsert = false ]) : bool|null|void
Parameters
$data :
$upsert : bool = false
Return values
bool|null|void

insertWithStreamingBuffer()

Streaming Insert a record in db. It couldn't be deleted or updated before 30' after insertion

public insertWithStreamingBuffer( $data) : bool|null|void
Parameters
$data :
Return values
bool|null|void

join()

public join( $type, DataBQ &$object,  $first_field,  $join_field[,  $extraon = null ]) : mixed
Parameters
$type :

Could be inner or left

$object : DataBQ
$first_field :

string field of the local object to join with

$join_field :

string field of the join object to match

$extraon : = null

string any other extra condition

onlyCreateQuery()

Define When I want to build a query but I do not want to be executed I call this method with true value

public onlyCreateQuery( $boolean) : mixed
Parameters
$boolean :

query()

public query(mixed $title, mixed $_q[, mixed $params = [] ]) : mixed
Parameters
$title : mixed
$_q : mixed
$params : mixed = []

reset()

Reset init values

public reset() : mixed

setExtraWhere()

public setExtraWhere(mixed $extraWhere) : mixed
Parameters
$extraWhere : mixed

setGroupBy()

public setGroupBy( $group) : mixed
Parameters
$group :

String The group by fields

setLimit()

Set a limit in the select query or fetch method.

public setLimit(int $limit) : mixed
Parameters
$limit : int

setOffset()

Set a offset in the select query or fetch method.

public setOffset(int $offset) : mixed
Parameters
$offset : int

setOrder()

Set Order into a query with a field

public setOrder( $field[,  $type = 'ASC' ]) : mixed
Parameters
$field :
$type : = 'ASC'

setPage()

Set a page in the select query or fetch method.

public setPage(int $page) : mixed
Parameters
$page : int

setQueryFields()

Defines the fields to return in a query. If empty it will return all of them

public setQueryFields( $fields) : mixed
Parameters
$fields :

setQueryWhere()

Array with key=>value Especial values: '__null__' '__notnull__' '__empty__' '__notempty__'

public setQueryWhere(array<string|int, mixed> $keysWhere) : mixed
Parameters
$keysWhere : array<string|int, mixed>

setView()

public setView(mixed $view) : mixed
Parameters
$view : mixed

setVirtualField()

public setVirtualField( $field,  $value) : mixed
Parameters
$field :

String virtual field name

$value :

String value or other field

softDelete()

Update a record in db It requires to add always the following condition: and _created < TIMESTAMP_SUB(_created, INTERVAL 30 MINUTE) because you can not update or delete records inserted before 30' has passed

public softDelete(mixed $key) : bool|null|void
Parameters
$key : mixed
Return values
bool|null|void

test()

Just a test query to know if the service works

public test() : array<string|int, mixed>|void
Return values
array<string|int, mixed>|void

unsetOrder()

About Order

public unsetOrder() : mixed

update()

Update a record in db It requires to add always the following condition: and _created < TIMESTAMP_SUB(_created, INTERVAL 30 MINUTE) because you can not update or delete records inserted before 30' has passed

public update( $data[, mixed $record_readed = [] ]) : bool|null|void
Parameters
$data :
$record_readed : mixed = []
Return values
bool|null|void

upsert()

Upsert a record in db

public upsert( $data) : bool|null|void
Parameters
$data :
Return values
bool|null|void

useMapping()

Active or deactive mapping of fields

public useMapping([bool $use = true ]) : mixed
Parameters
$use : bool = true

_feed()

Feed a table with $data

private _feed( $table_id,  &$data) : bool|void
Parameters
$table_id :
$data :
Return values
bool|void

_query()

Execute a query in BigQuery

private _query( $q[, mixed $params = [] ]) : array<string|int, mixed>|void
Parameters
$q :
$params : mixed = []
Return values
array<string|int, mixed>|void

processSchema()

Process Schema

private processSchema( $schema) : bool|void
Parameters
$schema :
Return values
bool|void

        
On this page

Search results