AbstractDatabase
extends AbstractCrud
in package
This is a simple Database implementation that other Database can inherit from.
Table of Contents
Properties
- $affected_rows : int
- $database : MySqlDTO|PostgreSqlDTO|mixed
- $executed : string
- $field_types : array<string|int, array<string|int, mixed>>
- $functions : array<string|int, string>
- $insert_id : int
- $queried : string
Methods
- __construct() : mixed
- count() : int
- Retrieve total existing record.
- delete() : static
- Return an instance with deleted record.
- getAffectedRows() : int
- Retrieve number of affected rows in the last execute() operation.
- getExecuted() : string
- Retrieve the last command that was run in execute() operation.
- getInsertId() : int
- Retrieve the ID generated in the last execute() operation.
- getQueried() : string
- Retrieve the last command that was run in query() operation.
- insert() : static
- Return an instance with inserted new record.
- isFunction() : bool
- Check if data expression is sql function.
- record() : array<string, mixed>
- Retrieve single row record from query command.
- select() : array<string|int, array<string, mixed>>
- Retrieve multiple row records from query command.
- update() : static
- Return an instance with updated record.
- databaseFactory() : object
- Retrieve database factory.
- functionsFactory() : array<string|int, string>
- Retrieve functions factory.
- getFieldOperant() : string
- Retrieve field value.
- getFieldType() : int
- Retrieve field type.
- getFieldValue() : string
- Retrieve field value.
- getIdentifier() : string
- Retrieve identifier name.
- getResultValue() : mixed
- Retrieve query result value.
- getSqlField() : string
- Retrieve SQL field statement.
- getSqlFilter() : string
- Retrieve SQL filter statement.
- getSqlGroup() : string
- Retrieve SQL group statement.
- getSqlInsert() : array<string, string>
- Retrieve SQL insert statements.
- getSqlOrder() : string
- Retrieve SQL order statement.
- getSqlSet() : string
- Retrieve SQL data statement.
- getSqlTable() : string
- Retrieve SQL table statement.
Properties
$affected_rows
protected
int
$affected_rows
= 0
$database
protected
MySqlDTO|PostgreSqlDTO|mixed
$database
= null
$executed
protected
string
$executed
= ""
$field_types
protected
array<string|int, array<string|int, mixed>>
$field_types
= []
$functions
protected
array<string|int, string>
$functions
= []
$insert_id
protected
int
$insert_id
= 0
$queried
protected
string
$queried
= ""
Methods
__construct()
public
__construct([array<string, mixed> $Config = [] ]) : mixed
Parameters
- $Config : array<string, mixed> = []
-
The database configuration.
Tags
count()
Retrieve total existing record.
public
count(array<string, mixed> $Data) : int
Parameters
- $Data : array<string, mixed>
-
The count data.
Tags
Return values
intdelete()
Return an instance with deleted record.
public
delete(array<string, mixed> $Data) : static
Parameters
- $Data : array<string, mixed>
-
The delete data.
Tags
Return values
staticgetAffectedRows()
Retrieve number of affected rows in the last execute() operation.
public
getAffectedRows() : int
Return values
intgetExecuted()
Retrieve the last command that was run in execute() operation.
public
getExecuted() : string
Return values
stringgetInsertId()
Retrieve the ID generated in the last execute() operation.
public
getInsertId() : int
Return values
intgetQueried()
Retrieve the last command that was run in query() operation.
public
getQueried() : string
Return values
stringinsert()
Return an instance with inserted new record.
public
insert(array<string, mixed> $Data) : static
Parameters
- $Data : array<string, mixed>
-
The create data.
Tags
Return values
staticisFunction()
Check if data expression is sql function.
public
isFunction(string $Expression) : bool
Parameters
- $Expression : string
-
The sql expression.
Return values
boolrecord()
Retrieve single row record from query command.
public
record(array<string, mixed> $Read) : array<string, mixed>
Parameters
- $Read : array<string, mixed>
-
The read data.
Tags
Return values
array<string, mixed>select()
Retrieve multiple row records from query command.
public
select(array<string, mixed> $Data) : array<string|int, array<string, mixed>>
Parameters
- $Data : array<string, mixed>
-
The read data.
Tags
Return values
array<string|int, array<string, mixed>>update()
Return an instance with updated record.
public
update(array<string, mixed> $Data) : static
Parameters
- $Data : array<string, mixed>
-
The update data.
Tags
Return values
staticdatabaseFactory()
Retrieve database factory.
protected
abstract databaseFactory(array<string, mixed> $Config) : object
Parameters
- $Config : array<string, mixed>
-
The database configuration.
Tags
Return values
objectfunctionsFactory()
Retrieve functions factory.
protected
abstract functionsFactory() : array<string|int, string>
Tags
Return values
array<string|int, string>getFieldOperant()
Retrieve field value.
protected
getFieldOperant(mixed $Value, bool $UseSensitiveCase) : string
Parameters
- $Value : mixed
-
The value
- $UseSensitiveCase : bool
-
Use sensitive-case operator.
Return values
stringgetFieldType()
Retrieve field type.
protected
getFieldType(mixed $Type) : int
Parameters
- $Type : mixed
-
The database type
Return values
intgetFieldValue()
Retrieve field value.
protected
getFieldValue(mixed $Value) : string
Parameters
- $Value : mixed
-
The value
Return values
stringgetIdentifier()
Retrieve identifier name.
protected
abstract getIdentifier(string $UnidentifiedName) : string
Parameters
- $UnidentifiedName : string
-
The unidentified name.
Return values
stringgetResultValue()
Retrieve query result value.
protected
getResultValue(array<string, int> $Types, string $Name, mixed $Value) : mixed
Parameters
- $Types : array<string, int>
-
Result types
- $Name : string
-
Field name
- $Value : mixed
-
Field value
getSqlField()
Retrieve SQL field statement.
protected
getSqlField(array<int|string, string> $Field) : string
Parameters
- $Field : array<int|string, string>
-
The field data.
Return values
stringgetSqlFilter()
Retrieve SQL filter statement.
protected
getSqlFilter(array<string|int, mixed> $Filter, bool $UseSensitiveCase[, bool $UseOrCondition = false ]) : string
Parameters
- $Filter : array<string|int, mixed>
-
The filter data.
- $UseSensitiveCase : bool
-
Use sensitive-case operator.
- $UseOrCondition : bool = false
-
Use OR condition.
Return values
stringgetSqlGroup()
Retrieve SQL group statement.
protected
getSqlGroup(array<string|int, string> $Group) : string
Parameters
- $Group : array<string|int, string>
-
The group data.
Return values
stringgetSqlInsert()
Retrieve SQL insert statements.
protected
getSqlInsert(array<string, mixed> $Data) : array<string, string>
Parameters
- $Data : array<string, mixed>
-
The data.
Return values
array<string, string>getSqlOrder()
Retrieve SQL order statement.
protected
getSqlOrder(array<string, string> $Order) : string
Parameters
- $Order : array<string, string>
-
The order data.
Return values
stringgetSqlSet()
Retrieve SQL data statement.
protected
getSqlSet(array<string, mixed> $Data) : string
Parameters
- $Data : array<string, mixed>
-
The set data.
Return values
stringgetSqlTable()
Retrieve SQL table statement.
protected
getSqlTable(string|array<string|int, string> $Table) : string
Parameters
- $Table : string|array<string|int, string>
-
The table data.