CoreModel
in package
$this->core->model Class to manage Data Models
Table of Contents
Properties
- $cache : mixed
- $db : CloudSQL
- $dbConnection : mixed
- $dbConnections : mixed
- $error : mixed
- $errorCode : mixed
- $errorMsg : mixed
- $models : mixed
- $mongoDB : DataMongoDB
- $core : mixed
Methods
- __construct() : mixed
- dbClose() : mixed
- Close Database connections.
- dbCommand() : mixed
- dbDelete() : bool|null|void
- Delete a record into the database. If it exist rewrite it
- dbInit() : bool
- Init a DB connection
- dbInsert() : bool|null|void
- Insert
- dbQuery() : array<string|int, mixed>|void
- Excute the query and return the result if there is no errors
- dbUpdate() : bool|null|void
- Update a record into the database
- dbUpsert() : bool|null|void
- Upsert a record into the database. If it exist rewrite it
- getCache() : mixed
- Get var Cache of the module
- getModelObject() : DataStore|DataSQL|void
- listmodels() : array<string|int, mixed>
- Returns the array keys of the models
- mongoInit() : bool
- Init a Mongo connection
- processModels() : mixed
- Process the model received in models
- readCache() : mixed
- Reset Cache of the module
- readModels() : bool
- Read models from specific Path
- readModelsFromCloudFramework() : bool|void
- Read models from CloudFramework
- resetCache() : mixed
- Reset Cache of the module
- updateCache() : mixed
- Update Cache of the module
- addError() : mixed
Properties
$cache
public
mixed
$cache
= \null
$db
public
CloudSQL
$db
= \null
$dbConnection
public
mixed
$dbConnection
= 'default'
$dbConnections
public
mixed
$dbConnections
= []
$error
public
mixed
$error
= \false
$errorCode
public
mixed
$errorCode
= \null
$errorMsg
public
mixed
$errorMsg
= \null
$models
public
mixed
$models
= \null
$mongoDB
public
DataMongoDB
$mongoDB
= \null
$core
protected
mixed
$core
Methods
__construct()
public
__construct(Core7 &$core) : mixed
Parameters
- $core : Core7
dbClose()
Close Database connections.
public
dbClose([string $connection = '' ]) : mixed
Parameters
- $connection : string = ''
-
Optional it specify to close a specific connection instead of all
dbCommand()
public
dbCommand(mixed $title, mixed $q[, mixed $params = [] ]) : mixed
Parameters
- $title : mixed
- $q : mixed
- $params : mixed = []
dbDelete()
Delete a record into the database. If it exist rewrite it
public
dbDelete( $title, $table, &$data) : bool|null|void
Parameters
Return values
bool|null|voiddbInit()
Init a DB connection
public
dbInit([string $connection = '' ][, array<string|int, mixed> $db_credentials = [] ]) : bool
Parameters
- $connection : string = ''
-
optional connection to use. By default $this->dbConnection
- $db_credentials : array<string|int, mixed> = []
-
optional connection to use. By default $this->dbConnection
Return values
booldbInsert()
Insert
public
dbInsert( $title, $table, &$data) : bool|null|void
Parameters
Return values
bool|null|voiddbQuery()
Excute the query and return the result if there is no errors
public
dbQuery(mixed $title, $SQL[, $params = [] ][, $types = null ]) : array<string|int, mixed>|void
Parameters
- $title : mixed
- $SQL :
- $params : = []
- $types : = null
-
type format of the fields. Example: ['id':'int(10)']
Return values
array<string|int, mixed>|voiddbUpdate()
Update a record into the database
public
dbUpdate( $title, $table, &$data) : bool|null|void
Parameters
Return values
bool|null|voiddbUpsert()
Upsert a record into the database. If it exist rewrite it
public
dbUpsert( $title, $table, &$data) : bool|null|void
Parameters
Return values
bool|null|voidgetCache()
Get var Cache of the module
public
getCache(mixed $var) : mixed
Parameters
- $var : mixed
getModelObject()
public
getModelObject(string $object[, array<string|int, mixed> $options = [] ]) : DataStore|DataSQL|void
Parameters
- $object : string
-
We expect a '(db|ds):model_name' or just 'model_name'
- $options : array<string|int, mixed> = []
-
optional options string $namespace says what namespace to use for datastore objects string $projectId says what project_id to use for datastore/bq objects string $cf_models_api_key is the API-KEY to use for CloudFrameworkDataModels and read the structure remotelly
Return values
DataStore|DataSQL|voidlistmodels()
Returns the array keys of the models
public
listmodels() : array<string|int, mixed>
Return values
array<string|int, mixed>mongoInit()
Init a Mongo connection
public
mongoInit([mixed $uri = '' ]) : bool
Parameters
- $uri : mixed = ''
Return values
boolprocessModels()
Process the model received in models
public
processModels( $models) : mixed
Parameters
readCache()
Reset Cache of the module
public
readCache() : mixed
readModels()
Read models from specific Path
public
readModels( $path) : bool
Parameters
Return values
boolreadModelsFromCloudFramework()
Read models from CloudFramework
public
readModelsFromCloudFramework( $models, $api_key) : bool|void
Parameters
Return values
bool|voidresetCache()
Reset Cache of the module
public
resetCache() : mixed
updateCache()
Update Cache of the module
public
updateCache(mixed $var, mixed $data) : mixed
Parameters
- $var : mixed
- $data : mixed
addError()
private
addError(mixed $msg[, mixed $code = 0 ]) : mixed
Parameters
- $msg : mixed
- $code : mixed = 0