PostgreSql
extends AbstractDatabase
in package
Simple PostgreSQL implementation.
Table of Contents
Properties
- $affected_rows : int
- $database : MySqlDTO|PostgreSqlDTO|mixed
- $executed : string
- $field_types : 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.
- escape() : string
- Escapes special characters in a string for use in an SQL statement.
- execute() : static
- Return an instance with executed query command.
- 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.
- query() : array<string|int, array<string, mixed>>
- Retrieve records from query command.
- 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() : PostgreSqlDTO
- Retrieve postgresql database.
- functionsFactory() : array<string|int, string>
- Retrieve postgresql functions.
- 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.
- getResultTypes() : array<string, int>
- Retrieve query result types.
Properties
$affected_rows
protected
int
$affected_rows
= 0
$database
protected
MySqlDTO|PostgreSqlDTO|mixed
$database
= null
$executed
protected
string
$executed
= ""
$field_types
protected
mixed
$field_types
= [\Samy\Database\Constant\DatabaseFieldType::INTEGER => ["int2", "int4", "int8", "bool"], \Samy\Database\Constant\DatabaseFieldType::FLOAT => ["numeric", "float4", "float8", "money"], \Samy\Database\Constant\DatabaseFieldType::STRING => ["bpchar", "varchar", "text", "tsquery", "tsvector", "uuid", "xml", "json", "jsonb", "name"], \Samy\Database\Constant\DatabaseFieldType::TIME => ["date", "time", "timestamp", "timestamptz", "interval"]]
$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
staticescape()
Escapes special characters in a string for use in an SQL statement.
public
escape(string $UnescapedString) : string
Escapes special characters in the unescaped_string, taking into account the current character set of the connection so that it is safe to place it in a execute() or query(). If binary data is to be inserted, this function must be used.
This function must always (with few exceptions) be used to make data safe before sending a query.
Parameters
- $UnescapedString : string
-
The unescaped string.
Return values
stringexecute()
Return an instance with executed query command.
public
execute(string $Command) : static
Parameters
- $Command : string
-
The sql command.
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
boolquery()
Retrieve records from query command.
public
query(string $Command) : array<string|int, array<string, mixed>>
Parameters
- $Command : string
-
The sql command.
Tags
Return values
array<string|int, array<string, mixed>>record()
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 postgresql database.
protected
databaseFactory(array<string, mixed> $Data) : PostgreSqlDTO
Parameters
- $Data : array<string, mixed>
-
The data configuration.
Tags
Return values
PostgreSqlDTOfunctionsFactory()
Retrieve postgresql functions.
protected
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
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.
Return values
stringgetResultTypes()
Retrieve query result types.
private
getResultTypes(PostgreSqlResultDTO $ResultSet) : array<string, int>
Parameters
- $ResultSet : PostgreSqlResultDTO
-
The query result set