PHP Database

AbstractCrud extends AbstractSql
in package
implements CrudInterface

AbstractYes

This is a simple CRUD implementation that other CRUD can inherit from.

Table of Contents

Interfaces

CrudInterface
Describes CRUD interface.

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

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.
getFieldOperant()  : string
Retrieve field value.
getFieldType()  : int
Retrieve field type.
getFieldValue()  : string
Retrieve field value.
getIdentifier()  : string
Retrieve identifier name.
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

$database

protected MySqlDTO|PostgreSqlDTO|mixed $database = null

$field_types

protected array<string|int, array<string|int, mixed>> $field_types = []

$functions

protected array<string|int, string> $functions = []

Methods

count()

Retrieve total existing record.

public count(array<string, mixed> $Data) : int
Parameters
$Data : array<string, mixed>

The count data.

Tags
throws
DatabaseException

If error.

throws
ValidationException

If invalid.

Return values
int

delete()

Return an instance with deleted record.

public delete(array<string, mixed> $Data) : static
Parameters
$Data : array<string, mixed>

The delete data.

Tags
throws
DatabaseException

If error.

throws
ValidationException

If invalid.

Return values
static

getAffectedRows()

Retrieve number of affected rows in the last execute() operation.

public getAffectedRows() : int
Return values
int

getExecuted()

Retrieve the last command that was run in execute() operation.

public getExecuted() : string
Return values
string

getInsertId()

Retrieve the ID generated in the last execute() operation.

public getInsertId() : int
Return values
int

getQueried()

Retrieve the last command that was run in query() operation.

public getQueried() : string
Return values
string

insert()

Return an instance with inserted new record.

public insert(array<string, mixed> $Data) : static
Parameters
$Data : array<string, mixed>

The create data.

Tags
throws
DatabaseException

If error.

throws
ValidationException

If invalid.

Return values
static

isFunction()

Check if data expression is sql function.

public isFunction(string $Expression) : bool
Parameters
$Expression : string

The sql expression.

Return values
bool

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
throws
DatabaseException

If error.

throws
ValidationException

If invalid.

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
throws
DatabaseException

If error.

throws
ValidationException

If invalid.

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
throws
DatabaseException

If error.

throws
ValidationException

If invalid.

Return values
static

getFieldOperant()

Retrieve field value.

protected getFieldOperant(mixed $Value, bool $UseSensitiveCase) : string
Parameters
$Value : mixed

The value

$UseSensitiveCase : bool

Use sensitive-case operator.

Return values
string

getFieldType()

Retrieve field type.

protected getFieldType(mixed $Type) : int
Parameters
$Type : mixed

The database type

Return values
int

getFieldValue()

Retrieve field value.

protected getFieldValue(mixed $Value) : string
Parameters
$Value : mixed

The value

Return values
string

getIdentifier()

Retrieve identifier name.

protected abstract getIdentifier(string $UnidentifiedName) : string
Parameters
$UnidentifiedName : string

The unidentified name.

Return values
string

getSqlField()

Retrieve SQL field statement.

protected getSqlField(array<int|string, string> $Field) : string
Parameters
$Field : array<int|string, string>

The field data.

Return values
string

getSqlFilter()

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
string

getSqlGroup()

Retrieve SQL group statement.

protected getSqlGroup(array<string|int, string> $Group) : string
Parameters
$Group : array<string|int, string>

The group data.

Return values
string

getSqlInsert()

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
string

getSqlSet()

Retrieve SQL data statement.

protected getSqlSet(array<string, mixed> $Data) : string
Parameters
$Data : array<string, mixed>

The set data.

Return values
string

getSqlTable()

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
string

        
On this page

Search results