| Methods |
public
static
|
connect(
string|array<string, string> $dsn,
string $user = null,
string $password = null,
array<string, mixed> $defaults = [],
): self
Connects database.
Parameters
| $dsn |
Format as PDO DSN or use "mysql://user:pass@host/db;option=blah",
leaving user and password arguments = null
|
|
#
|
public
|
disconnect(): void
Disconnect from database explicitly.
Disconnect from database explicitly.
Overriden by
|
#
|
public
|
add(Model $model, array<string, mixed> $defaults = []): void
Associate model with the data driver.
Associate model with the data driver.
Overriden by
|
#
|
protected
|
initPersistence(Model $m): void
Extend this method to enhance model to work with your persistence. Here
you can define additional methods or store…
Extend this method to enhance model to work with your persistence. Here
you can define additional methods or store additional data. This method
is executed before model's init().
Overriden by
|
#
|
public
|
atomic<T>(Closure(): T $fx): T
Atomic executes operations within one begin/end transaction. Not all
persistencies will support atomic operations, so…
Atomic executes operations within one begin/end transaction. Not all
persistencies will support atomic operations, so by default we just
don't do anything.
Overriden by
|
#
|
public
|
getDatabasePlatform(): AbstractPlatform
|
#
|
public
|
tryLoad(Model $model, mixed $id): array<string, mixed>|null
Tries to load data record, but will not fail if record can't be loaded.
Tries to load data record, but will not fail if record can't be loaded.
Overriden by
|
#
|
public
|
load(Model $model, mixed $id): array<string, mixed>
Loads a record from model and returns a associative array.
Loads a record from model and returns a associative array.
|
#
|
public
|
insert(Model $model, array<string, mixed> $data): mixed
Inserts record in database and returns new record ID.
Inserts record in database and returns new record ID.
|
#
|
protected
|
insertRaw(Model $model, array<scalar|null> $dataRaw): mixed
|
#
|
public
|
update(Model $model, mixed $id, array<string, mixed> $data): void
Updates record in database.
Updates record in database.
|
#
|
protected
|
updateRaw(Model $model, mixed $idRaw, array<scalar|null> $dataRaw): void
|
#
|
public
|
delete(Model $model, mixed $id): void
Deletes record from database.
Deletes record from database.
|
#
|
protected
|
deleteRaw(Model $model, mixed $idRaw): void
|
#
|
public
|
typecastSaveRow(Model $model, array<string, mixed> $row): array<scalar|Expressionable|null>
Will convert one row of data from native PHP types into
persistence types. This will also take care of the "actual"…
Will convert one row of data from native PHP types into
persistence types. This will also take care of the "actual"
field keys.
Overriden by
|
#
|
public
|
typecastLoadRow(Model $model, array<string, scalar|null> $row): array<string, mixed>
Will convert one row of data from Persistence-specific
types to PHP native types.
Will convert one row of data from Persistence-specific
types to PHP native types.
NOTE: Please DO NOT perform "actual" field mapping here, because data
may be "aliased" from SQL persistencies or mapped depending on persistence
driver.
|
#
|
private
|
_typecastPreField(Field $field, mixed $value, bool $fromLoad): ($value is scalar ? scalar : mixed)
|
#
|
public
|
typecastSaveField(Field $field, mixed $value): scalar|Expressionable|null
Prepare value of a specific field by converting it to
persistence-friendly format.
Prepare value of a specific field by converting it to
persistence-friendly format.
Overriden by
|
#
|
public
|
typecastLoadField(Field $field, scalar|null $value): mixed
Cast specific field value from the way how it's stored inside
persistence to a PHP format.
Cast specific field value from the way how it's stored inside
persistence to a PHP format.
Overriden by
|
#
|
protected
|
_typecastSaveField(Field $field, mixed $value): scalar|null
This is the actual field typecasting, which you can override in your
persistence to implement necessary typecasting.
This is the actual field typecasting, which you can override in your
persistence to implement necessary typecasting.
Overriden by
|
#
|
protected
|
_typecastLoadField(Field $field, scalar $value): mixed
This is the actual field typecasting, which you can override in your
persistence to implement necessary typecasting.
This is the actual field typecasting, which you can override in your
persistence to implement necessary typecasting.
Overriden by
|
#
|