Interface for working with record sets.
| 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. |
Commits the translation.
It might throw an exception in the case of any errors.
Counts records based on the where clause.
| 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 the number of records.
Counts records based on the query.
| Name | Pass type | Value type | Default value | Description |
|---|---|---|---|---|
| $query | by value | string |
The query to be used. |
Returns the number of records.
Deletes records by a given where clause.
| 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. |
Deletes records by a given query.
| Name | Pass type | Value type | Default value | Description |
|---|---|---|---|---|
| $query | by value | string |
The query to be used. |
Defines the field mappings for working with record sets based on a table.
| 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. |
Defines the field mappings for working with record sets based on a query.
| 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. |
Escapes the string so that it can be used in the query without causing an error.
| Name | Pass type | Value type | Default value | Description |
|---|---|---|---|---|
| $str | by value | string |
The string to be escaped. |
Returns the escaped string.
Formats the date to a string compatible for the corresponding database.
| Name | Pass type | Value type | Default value | Description |
|---|---|---|---|---|
| $date | by value | int |
The date value as timestamp. |
Returns the string representation of the date compatible for the corresponding database.
Formats the date/time to a string compatible for the corresponding database.
| Name | Pass type | Value type | Default value | Description |
|---|---|---|---|---|
| $datetime | by value | int |
The date/time value as timestamp. |
Returns the string representation of the date/time compatible for the corresponding database.
Returns the dbworker to be used for working with the database.
Returns the dbworker to be used for working with the database.
Loads a record into an array in the form "field_name" => "value" based on a table.
| 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. |
Loads a record into an array in the form "field_name" => "value" based on a query.
| 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. |
Loads records into an array in the form
$records["key_field1"]["key_field2"]["key_fieldN"]["field_name"] = "value"
based on a table.
| 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. |
Loads records into an array in the form
$records["key_field1"]["key_field2"]["key_fieldN"]["field_name"] = "value"
based on a query.
| 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. |
Rolls back the translation.
It might throw an exception in the case of any errors.
Saves a record from an array in the form "field_name" => "value" into the table.
| 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. |
Saves records from an array in the form $records["key_field1"]["key_field2"]["key_fieldN"]["field_name"] = "value" into the table.
| 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. |
Sets the dbworker to be used for working with the database.
| Name | Pass type | Value type | Default value | Description |
|---|---|---|---|---|
| $dbworker | by value | \SmartFactory\DatabaseWorkers\DBWorker |
The dbworker to be used for working with the database. |
Starts the translation.
It might throw an exception in the case of any errors.