CloudSQL
in package
[$sql = $this->core->loadClass('CloudSQL')] Class to handle CloudSQL (mysql) interactions.
Feel free to use a distribute it. last-update 2024-01-10
Table of Contents
Properties
- $_affectedRows : mixed
- $_cloudAutoSelectFields : mixed
- $_cloudDependences : mixed
- $_cloudFilterToAvoidCalculation : mixed
- $_cloudFilterWhereFields : mixed
- $_cloudReferalFields : mixed
- $_cloudWhereFields : mixed
- $_db : mysqli
- $_dbcharset : mixed
- $_dbdatabase : mixed
- $_dbpassword : mixed
- $_dbport : mixed
- $_dbProxy : mixed
- $_dbProxyHeaders : mixed
- $_dbserver : mixed
- $_dbsocket : mixed
- $_dbtype : mixed
- $_dbuser : mixed
- $_debug : mixed
- $_error : mixed
- $_lastExecutionMicrotime : mixed
- $_lastInsertId : mixed
- $_lastQuery : mixed
- $_lastRes : mixed
- $_limit : mixed
- $_onlyCreateQuery : mixed
- $_page : mixed
- $_qObject : mixed
- $_queryFieldTypes : mixed
- $_version : mixed
- $affected : mixed
- $arrayedResult : mixed
- $cfmode : mixed
- $rawResults : mixed
- $records : mixed
- $result : mixed
- $_dblink : mixed
- $core : mixed
Methods
- __construct() : mixed
- CLOUD SQL Constructor
- _buildQuery() : array<string|int, mixed>|false|mixed|string|array<string|int, string>|null
- Build a Query receiving a string with %s as first parameter and an array of values as second paramater
- addFieldDependence() : mixed
- addFilterWhereField() : mixed
- addQueryObjectWhere() : mixed
- addReferalField() : mixed
- addWhereField() : mixed
- avoidFilterCalculation() : mixed
- close() : mixed
- Close the opened connection
- cloudFrameWork() : mixed
- command() : mixed
- connect() : bool
- error() : bool
- Return true if there is any error
- getAffectedRows() : mixed
- Return the number of affected rows in the las query
- getConf() : mixed
- getDataFromQuery() : mixed
- getError() : mixed
- Return the last error produced. It will be an array
- getFieldDependence() : mixed
- getFilterWhereField() : mixed
- getHashFromArray() : mixed
- getInsertId() : mixed
- Return last id of the inserted record
- getInterfaceModelFromTable() : array<string|int, mixed>
- getLimit() : mixed
- getModelFromTable() : array<string|int, mixed>
- Return the CloudFrameWork-io Model from a DB table
- getPage() : mixed
- getQuery() : mixed
- Return last query executed
- getQueryFromSearch() : array<string|int, mixed>|false|mixed|string|array<string|int, string>|null
- Return a safe query taking the following fields:
- getQueryObject() : mixed
- Return $this->_qObject[$id]
- getReferalField() : mixed
- getSecuredSqlString() : mixed
- getSimpleModelFromTable() : mixed
- getWhereField() : mixed
- initQueryObject() : mixed
- isAutoSelectField() : mixed
- isAvoidFilterCalculation() : mixed
- joinQueryValues() : array<string|int, mixed>|mixed|string|array<string|int, string>|null
- Join $values array with $q string wich contains %s elements
- loadCoreConfigVars() : 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
- scapeValue() : string
- Apply $this->_db->real_escape_string or addslashes if there is not db objext
- setAutoSelectField() : mixed
- setConf() : mixed
- setDB() : mixed
- Asssign the Database to work with
- setError() : mixed
- Assign an error
- setFieldDependence() : mixed
- setFilterWhereField() : mixed
- setLimit() : mixed
- setPage() : mixed
- setQueryObjectData() : mixed
- setQueryObjectOrder() : mixed
- setQueryObjectSelectFields() : mixed
- setQueryObjectTable() : mixed
- setQueryObjectWhere() : mixed
- setReferalField() : mixed
- setWhereField() : mixed
- tableExists() : bool
- Check if the table exist avoiding to consult the schema because it is very slow.
- unsetAutoSelectField() : mixed
Properties
$_affectedRows
public
mixed
$_affectedRows
= \null
$_cloudAutoSelectFields
public
mixed
$_cloudAutoSelectFields
= array()
$_cloudDependences
public
mixed
$_cloudDependences
= array()
$_cloudFilterToAvoidCalculation
public
mixed
$_cloudFilterToAvoidCalculation
= array()
$_cloudFilterWhereFields
public
mixed
$_cloudFilterWhereFields
= array()
$_cloudReferalFields
public
mixed
$_cloudReferalFields
= array()
$_cloudWhereFields
public
mixed
$_cloudWhereFields
= array()
$_db
public
mysqli
$_db
$_dbcharset
public
mixed
$_dbcharset
= ''
$_dbdatabase
public
mixed
$_dbdatabase
$_dbpassword
public
mixed
$_dbpassword
$_dbport
public
mixed
$_dbport
= '3306'
$_dbProxy
public
mixed
$_dbProxy
= \null
$_dbProxyHeaders
public
mixed
$_dbProxyHeaders
= \null
$_dbserver
public
mixed
$_dbserver
$_dbsocket
public
mixed
$_dbsocket
$_dbtype
public
mixed
$_dbtype
= 'mysql'
$_dbuser
public
mixed
$_dbuser
$_debug
public
mixed
$_debug
= \false
$_error
public
mixed
$_error
= []
$_lastExecutionMicrotime
public
mixed
$_lastExecutionMicrotime
= 0
$_lastInsertId
public
mixed
$_lastInsertId
= ''
$_lastQuery
public
mixed
$_lastQuery
= ''
$_lastRes
public
mixed
$_lastRes
= \false
$_limit
public
mixed
$_limit
= 10000
$_onlyCreateQuery
public
mixed
$_onlyCreateQuery
= \false
$_page
public
mixed
$_page
= 0
$_qObject
public
mixed
$_qObject
= array()
$_queryFieldTypes
public
mixed
$_queryFieldTypes
= array()
$_version
public
mixed
$_version
= '202401101'
$affected
public
mixed
$affected
$arrayedResult
public
mixed
$arrayedResult
$cfmode
public
mixed
$cfmode
= \true
$rawResults
public
mixed
$rawResults
$records
public
mixed
$records
$result
public
mixed
$result
$_dblink
protected
mixed
$_dblink
= \false
$core
protected
mixed
$core
= \null
Methods
__construct()
CLOUD SQL Constructor
public
__construct(Core7 &$core[, string $h = '' ][, string $u = '' ][, string $p = '' ][, string $db = '' ][, string $port = '3306' ][, string $socket = '' ][, string $charset = '' ]) : mixed
Parameters
- $core : Core7
- $h : string = ''
- $u : string = ''
- $p : string = ''
- $db : string = ''
- $port : string = '3306'
- $socket : string = ''
- $charset : string = ''
_buildQuery()
Build a Query receiving a string with %s as first parameter and an array of values as second paramater
public
_buildQuery( $args) : array<string|int, mixed>|false|mixed|string|array<string|int, string>|null
Parameters
Return values
array<string|int, mixed>|false|mixed|string|array<string|int, string>|nulladdFieldDependence()
public
addFieldDependence(mixed $field, mixed $dependence) : mixed
Parameters
- $field : mixed
- $dependence : mixed
addFilterWhereField()
public
addFilterWhereField(mixed $field, mixed $where[, mixed $values = array() ]) : mixed
Parameters
- $field : mixed
- $where : mixed
- $values : mixed = array()
addQueryObjectWhere()
public
addQueryObjectWhere(mixed $id, mixed $q[, mixed $v = '' ]) : mixed
Parameters
- $id : mixed
- $q : mixed
- $v : mixed = ''
addReferalField()
public
addReferalField(mixed $field, mixed $referal) : mixed
Parameters
- $field : mixed
- $referal : mixed
addWhereField()
public
addWhereField(mixed $field, mixed $where) : mixed
Parameters
- $field : mixed
- $where : mixed
avoidFilterCalculation()
public
avoidFilterCalculation(mixed $field) : mixed
Parameters
- $field : mixed
close()
Close the opened connection
public
close() : mixed
cloudFrameWork()
public
cloudFrameWork(mixed $action[, mixed $data = '' ][, mixed $mixValue = '' ][, mixed $order = '' ][, mixed $selectFields = '*' ][, mixed $page = 0 ]) : mixed
Parameters
- $action : mixed
- $data : mixed = ''
- $mixValue : mixed = ''
- $order : mixed = ''
- $selectFields : mixed = '*'
- $page : mixed = 0
command()
public
command() : mixed
connect()
public
connect([string $h = '' ][, string $u = '' ][, string $p = '' ][, string $db = '' ][, string $port = "3306" ][, string $socket = '' ][, string $charset = '' ]) : bool
Parameters
- $h : string = ''
-
Host
- $u : string = ''
-
User
- $p : string = ''
-
Password
- $db : string = ''
-
DB Name
- $port : string = "3306"
-
Port. Default 3306
- $socket : string = ''
-
Socket
- $charset : string = ''
-
Allow to specify a charste. Ex:
Return values
bool —True if connection is ok.
error()
Return true if there is any error
public
error() : bool
Return values
boolgetAffectedRows()
Return the number of affected rows in the las query
public
getAffectedRows() : mixed
getConf()
public
getConf(mixed $var) : mixed
Parameters
- $var : mixed
getDataFromQuery()
public
getDataFromQuery() : mixed
getError()
Return the last error produced. It will be an array
public
getError() : mixed
getFieldDependence()
public
getFieldDependence(mixed $field) : mixed
Parameters
- $field : mixed
getFilterWhereField()
public
getFilterWhereField(mixed $field) : mixed
Parameters
- $field : mixed
getHashFromArray()
public
getHashFromArray(mixed $arr) : mixed
Parameters
- $arr : mixed
getInsertId()
Return last id of the inserted record
public
getInsertId() : mixed
getInterfaceModelFromTable()
public
getInterfaceModelFromTable( $table) : array<string|int, mixed>
Parameters
Tags
Return values
array<string|int, mixed>getLimit()
public
getLimit() : mixed
getModelFromTable()
Return the CloudFrameWork-io Model from a DB table
public
getModelFromTable( $table) : array<string|int, mixed>
Parameters
Tags
Return values
array<string|int, mixed> —where array['model'] is the JSON model if array['table_exists]===true
getPage()
public
getPage() : mixed
getQuery()
Return last query executed
public
getQuery() : mixed
getQueryFromSearch()
Return a safe query taking the following fields:
public
getQueryFromSearch( $search[, false $fields = false ][, string $joints = "=" ][, string $operators = "AND" ]) : array<string|int, mixed>|false|mixed|string|array<string|int, string>|null
Parameters
Return values
array<string|int, mixed>|false|mixed|string|array<string|int, string>|nullgetQueryObject()
Return $this->_qObject[$id]
public
getQueryObject( $id) : mixed
Parameters
getReferalField()
public
getReferalField(mixed $field) : mixed
Parameters
- $field : mixed
getSecuredSqlString()
public
getSecuredSqlString(mixed $ret) : mixed
Parameters
- $ret : mixed
getSimpleModelFromTable()
public
getSimpleModelFromTable(mixed $table) : mixed
Parameters
- $table : mixed
getWhereField()
public
getWhereField(mixed $field) : mixed
Parameters
- $field : mixed
initQueryObject()
public
initQueryObject(mixed $id[, mixed $data = array() ][, mixed $mixValue = '' ]) : mixed
Parameters
- $id : mixed
- $data : mixed = array()
- $mixValue : mixed = ''
isAutoSelectField()
public
isAutoSelectField(mixed $field) : mixed
Parameters
- $field : mixed
isAvoidFilterCalculation()
public
isAvoidFilterCalculation(mixed $field) : mixed
Parameters
- $field : mixed
joinQueryValues()
Join $values array with $q string wich contains %s elements
public
joinQueryValues( $q, $values) : array<string|int, mixed>|mixed|string|array<string|int, string>|null
Parameters
Return values
array<string|int, mixed>|mixed|string|array<string|int, string>|nullloadCoreConfigVars()
public
loadCoreConfigVars() : mixed
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
scapeValue()
Apply $this->_db->real_escape_string or addslashes if there is not db objext
public
scapeValue( $value) : string
Parameters
Return values
stringsetAutoSelectField()
public
setAutoSelectField(mixed $field) : mixed
Parameters
- $field : mixed
setConf()
public
setConf(mixed $var, mixed $value) : mixed
Parameters
- $var : mixed
- $value : mixed
setDB()
Asssign the Database to work with
public
setDB( $db) : mixed
Parameters
setError()
Assign an error
public
setError(mixed $err) : mixed
Parameters
- $err : mixed
setFieldDependence()
public
setFieldDependence(mixed $field, mixed $dependence) : mixed
Parameters
- $field : mixed
- $dependence : mixed
setFilterWhereField()
public
setFilterWhereField(mixed $field, mixed $where[, mixed $values = array() ]) : mixed
Parameters
- $field : mixed
- $where : mixed
- $values : mixed = array()
setLimit()
public
setLimit(mixed $limit) : mixed
Parameters
- $limit : mixed
setPage()
public
setPage(mixed $page) : mixed
Parameters
- $page : mixed
setQueryObjectData()
public
setQueryObjectData(mixed $id, mixed $value) : mixed
Parameters
- $id : mixed
- $value : mixed
setQueryObjectOrder()
public
setQueryObjectOrder(mixed $id, mixed $value) : mixed
Parameters
- $id : mixed
- $value : mixed
setQueryObjectSelectFields()
public
setQueryObjectSelectFields(mixed $id, mixed $value) : mixed
Parameters
- $id : mixed
- $value : mixed
setQueryObjectTable()
public
setQueryObjectTable(mixed $id, mixed $value) : mixed
Parameters
- $id : mixed
- $value : mixed
setQueryObjectWhere()
public
setQueryObjectWhere(mixed $id, mixed $q[, mixed $v = '' ]) : mixed
Parameters
- $id : mixed
- $q : mixed
- $v : mixed = ''
setReferalField()
public
setReferalField(mixed $field, mixed $referal) : mixed
Parameters
- $field : mixed
- $referal : mixed
setWhereField()
public
setWhereField(mixed $field, mixed $where) : mixed
Parameters
- $field : mixed
- $where : mixed
tableExists()
Check if the table exist avoiding to consult the schema because it is very slow.
public
tableExists( $table) : bool
Parameters
Return values
boolunsetAutoSelectField()
public
unsetAutoSelectField(mixed $field) : mixed
Parameters
- $field : mixed