Interface: IRecordsetManager

Interface for working with record sets.

Known implementations

Authors

Oleg Schildt

Package

Source code

 

Methods
public

Commits the translation.

public

Counts records based on the where clause.

public

Counts records based on the query.

public

Deletes records by a given where clause.

public

Deletes records by a given query.

public

Defines the field mappings for working with record sets based on a table.

public

Defines the field mappings for working with record sets based on a query.

public

Escapes the string so that it can be used in the query without causing an error.

public

Formats the date to a string compatible for the corresponding database.

public

Formats the date/time to a string compatible for the corresponding database.

public

Returns the dbworker to be used for working with the database.

public

Loads a record into an array in the form "field_name" => "value" based on a table.

public

Loads a record into an array in the form "field_name" => "value" based on a query.

public

Loads records into an array in the form

public

Loads records into an array in the form

public

Rolls back the translation.

public

Saves a record from an array in the form "field_name" => "value" into the table.

public

Saves records from an array in the form $records["key_field1"]["key_field2"]["key_fieldN"]["field_name"] = "value" into the table.

public

Sets the dbworker to be used for working with the database.

public

Starts the translation.


Method: IRecordsetManager::commit_transaction()

public function commit_transaction(): void;

Commits the translation.

Returns

void

Throws

\SmartFactory\DatabaseWorkers\DBWorkerException

It might throw an exception in the case of any errors.

Authors

Oleg Schildt

Source code

See also


Method: IRecordsetManager::countRecords()

public function countRecords(array|string $where_clause): int;

Counts records based on the where clause.

Parameters

Name Pass type Value type Default value Description
$where_clause by value array|string

The where clause that should restrict the result. If an array of keys is passed, the where clause is build automatically based on it.

Returns

int

Returns the number of records.

Authors

Oleg Schildt

Source code

See also

Uses


Method: IRecordsetManager::countRecordsQuery()

public function countRecordsQuery(string $query): int;

Counts records based on the query.

Parameters

Name Pass type Value type Default value Description
$query by value string

The query to be used.

Returns

int

Returns the number of records.

Authors

Oleg Schildt

Source code

See also

Uses


Method: IRecordsetManager::deleteRecords()

public function deleteRecords(array|string $where_clause): void;

Deletes records by a given where clause.

Parameters

Name Pass type Value type Default value Description
$where_clause by value array|string

The where clause for the records to be deleted. If an array of keys is passed, the where clause is build automatically based on it.

Returns

void

Authors

Oleg Schildt

Source code

See also

Uses


Method: IRecordsetManager::deleteRecordsQuery()

public function deleteRecordsQuery(string $query): void;

Deletes records by a given query.

Parameters

Name Pass type Value type Default value Description
$query by value string

The query to be used.

Returns

void

Authors

Oleg Schildt

Source code

See also

Uses


Method: IRecordsetManager::describeTableFields()

public function describeTableFields(string $table, array $fields, array $key_fields): void;

Defines the field mappings for working with record sets based on a table.

Parameters

Name Pass type Value type Default value Description
$table by value string

The name of the table.

$fields by value array

The array of fields in the form "field name" => "field type".

$key_fields by value array

The array of key fields. These are the fields that are used to uniquely identify a record.

Returns

void

Authors

Oleg Schildt

Source code

See also


Method: IRecordsetManager::describeTableFieldsQuery()

public function describeTableFieldsQuery(array $fields, array $key_fields): void;

Defines the field mappings for working with record sets based on a query.

Parameters

Name Pass type Value type Default value Description
$fields by value array

The array of fields in the form "field name" => "field type".

$key_fields by value array

The array of key fields. These are the fields that are used to uniquely identify a record.

Returns

void

Authors

Oleg Schildt

Source code

See also


Method: IRecordsetManager::escape()

public function escape(string $str): string;

Escapes the string so that it can be used in the query without causing an error.

Parameters

Name Pass type Value type Default value Description
$str by value string

The string to be escaped.

Returns

string

Returns the escaped string.

Authors

Oleg Schildt

Source code

See also


Method: IRecordsetManager::format_date()

public function format_date(int $date): string;

Formats the date to a string compatible for the corresponding database.

Parameters

Name Pass type Value type Default value Description
$date by value int

The date value as timestamp.

Returns

string

Returns the string representation of the date compatible for the corresponding database.

Authors

Oleg Schildt

Source code

See also


Method: IRecordsetManager::format_datetime()

public function format_datetime(int $datetime): string;

Formats the date/time to a string compatible for the corresponding database.

Parameters

Name Pass type Value type Default value Description
$datetime by value int

The date/time value as timestamp.

Returns

string

Returns the string representation of the date/time compatible for the corresponding database.

Authors

Oleg Schildt

Source code

See also


Method: IRecordsetManager::getDBWorker()

public function getDBWorker(): ?\SmartFactory\DatabaseWorkers\DBWorker;

Returns the dbworker to be used for working with the database.

Returns

?\SmartFactory\DatabaseWorkers\DBWorker

Returns the dbworker to be used for working with the database.

Authors

Oleg Schildt

Source code

See also


Method: IRecordsetManager::loadRecord()

public function loadRecord(array &$record, array|string $where_clause): void;

Loads a record into an array in the form "field_name" => "value" based on a table.

Parameters

Name Pass type Value type Default value Description
$record by reference array

The target array where the data should be loaded.

$where_clause by value array|string

The where clause that should restrict the result. If an array of keys is passed, the where clause is build automatically based on it.

Returns

void

Authors

Oleg Schildt

Source code

See also

Uses


Method: IRecordsetManager::loadRecordQuery()

public function loadRecordQuery(array &$record, string $query): void;

Loads a record into an array in the form "field_name" => "value" based on a query.

Parameters

Name Pass type Value type Default value Description
$record by reference array

The target array where the data should be loaded.

$query by value string

The query to be used.

Returns

void

Authors

Oleg Schildt

Source code

See also

Uses


Method: IRecordsetManager::loadRecordSet()

public function loadRecordSet(array &$records, array|string $where_clause, string $order_clause = "", int $limit = 0 ) : void;

Loads records into an array in the form

Details

$records["key_field1"]["key_field2"]["key_fieldN"]["field_name"] = "value"

based on a table.

Parameters

Name Pass type Value type Default value Description
$records by reference array

The target array where the data should be loaded.

$where_clause by value array|string

The where clause that should restrict the result. If an array of keys is passed, the where clause is build automatically based on it.

$order_clause by value string ""

The order clause to sort the results.

$limit by value int 0

The limit how many records should be loaded. 0 for unlimited.

Returns

void

Authors

Oleg Schildt

Source code

See also

Uses


Method: IRecordsetManager::loadRecordSetQuery()

public function loadRecordSetQuery(array &$records, string $query): void;

Loads records into an array in the form

Details

$records["key_field1"]["key_field2"]["key_fieldN"]["field_name"] = "value"

based on a query.

Parameters

Name Pass type Value type Default value Description
$records by reference array

The target array where the data should be loaded.

$query by value string

The query to be used.

Returns

void

Authors

Oleg Schildt

Source code

See also

Uses


Method: IRecordsetManager::rollback_transaction()

public function rollback_transaction(): void;

Rolls back the translation.

Returns

void

Throws

\SmartFactory\DatabaseWorkers\DBWorkerException

It might throw an exception in the case of any errors.

Authors

Oleg Schildt

Source code

See also


Method: IRecordsetManager::saveRecord()

public function saveRecord(array &$record, array|string $where_clause, string $identity_field = ""): void;

Saves a record from an array in the form "field_name" => "value" into the table.

Parameters

Name Pass type Value type Default value Description
$record by reference array

The source array with the data to be saved.

$where_clause by value array|string

The where clause that should be used to define whether a record should be inserted or updated. If an array of keys is passed, the where clause is build automatically based on it.

$identity_field by value string ""

The name of the identity field if exists. If the identity field is specified and the record does not exist yet in the table, the source array is extended with a pair "identity field" => "identity value" issued by the database by this insert operation.

Returns

void

Authors

Oleg Schildt

Source code

See also

Uses


Method: IRecordsetManager::saveRecordSet()

public function saveRecordSet(array $records, array $parent_values = [], string $identity_field = ""): void;

Saves records from an array in the form $records["key_field1"]["key_field2"]["key_fieldN"]["field_name"] = "value" into the table.

Parameters

Name Pass type Value type Default value Description
$records by value array

The source array with the data to be saved.

$parent_values by value array []

If this recordset is a child subset of data to be saved, you can set the values of the foreign keys in the form "field_name" => "value".

$identity_field by value string ""

The name of the identity field if exists. If the identity field is specified and the record does not exist yet in the table, the source array is extended with a pair "identity field" => "identity value" issued by the database by this insert operation.

Returns

void

Authors

Oleg Schildt

Source code

See also

Uses


Method: IRecordsetManager::setDBWorker()

public function setDBWorker(\SmartFactory\DatabaseWorkers\DBWorker $dbworker): void;

Sets the dbworker to be used for working with the database.

Parameters

Name Pass type Value type Default value Description
$dbworker by value \SmartFactory\DatabaseWorkers\DBWorker

The dbworker to be used for working with the database.

Returns

void

Authors

Oleg Schildt

Source code

See also


Method: IRecordsetManager::start_transaction()

public function start_transaction(): void;

Starts the translation.

Returns

void

Throws

\SmartFactory\DatabaseWorkers\DBWorkerException

It might throw an exception in the case of any errors.

Authors

Oleg Schildt

Source code

See also