Class for working with record sets.
| Properties | |
|---|---|
|
protected
|
Internal variable for storing the dbworker. |
|
protected
|
Internal array for storing the target fields. |
|
protected
|
Internal array for storing the key fields. These are the fields that are used to uniquely identify a record. |
|
protected
|
Internal variable for storing the target table name. |
| Methods | |
|---|---|
|
protected
|
This is internal auxiliary function for converting an array to a where clause. |
|
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". |
|
public
|
Loads records into an array in the form |
|
public
|
Loads records into an array in the form |
|
public
|
Checks that the value is a number and returns it, or returns the string NULL if the value is empty. |
|
protected
|
This is internal auxiliary function for saving a record set from an array with key field values as array dimensions. |
|
public
|
Escapes the string so that it can be used in the query without causing an error or returns the sstring NULL if the string is empty. |
|
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. |
|
protected
|
This is internal auxiliary function for checking that the recordset manager is initialized correctly. |
Internal variable for storing the dbworker.
Internal array for storing the target fields.
Internal array for storing the key fields. These are the fields that are used to uniquely identify a record.
Internal variable for storing the target table name.
This is internal auxiliary function for converting an array to a where clause.
| Name | Pass type | Value type | Default value | Description |
|---|---|---|---|---|
| $where_clause | by reference | array|string |
The where clause that should be checked. If an array of keys is passed, the where clause is build based on it. |
It might throw an exception in the case if a field for the clause wad not described by the initialization.
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.
It might throw exceptions in the case of any errors.
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.
It might throw exceptions in the case of any errors.
Deletes records by a given 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. |
It might throw an exception in the case of any errors:
Deletes records by a given query.
| Name | Pass type | Value type | Default value | Description |
|---|---|---|---|---|
| $query | by value | string |
The query to be used. |
It might throw an exception in the case of any errors:
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. |
It might throw an exception in the case of any errors:
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. |
It might throw an exception in the case of any errors:
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.
It might throw exceptions in the case of any errors.
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 to one record. If an array of keys is passed, the where clause is build automatically based on it. |
It might throw an exception in the case of any errors:
Loads a record into an array in the form "field_name" => "value".
| 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. |
It might throw an exception in the case of any errors:
Loads records into an array in the form
$records["key_field1"]["key_field2"]["key_fieldN"]["field_name"] = "value".
baed 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. |
It might throw an exception in the case of any errors:
Loads records into an array in the form
$records["key_field1"]["key_field2"]["key_fieldN"]["field_name"] = "value".
baed 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. |
It might throw an exception in the case of any errors:
Checks that the value is a number and returns it, or returns the string NULL if the value is empty.
| Name | Pass type | Value type | Default value | Description |
|---|---|---|---|---|
| $str | by value | string |
The string to be escaped. |
Returns the escaped string.
It might throw an exception in the case of any errors.
This is internal auxiliary function for saving a record set from an array with key field values as array dimensions.
It expands this multidimensional array into the set of flat records suitable for call \SmartFactory\RecordsetManager::saveRecord().
| Name | Pass type | Value type | Default value | Description |
|---|---|---|---|---|
| $subarray | by value | array |
The current subarray ro be processed. |
|
| $key_fields | by value | array |
The array of the key fields. These are the fields that are used to uniquely identify a record. |
|
| $parent_values | by reference | array |
The array of the values of the foreign keys in the form "field_name" => "value". |
|
| $record | by reference | array |
The array where the resulting flat record is built. |
|
| $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. |
It might throw an exception in the case of any errors:
Escapes the string so that it can be used in the query without causing an error or returns the sstring NULL if the string is empty.
| Name | Pass type | Value type | Default value | Description |
|---|---|---|---|---|
| $str | by value | string |
The string to be escaped. |
Returns the escaped string.
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. |
It might throw an exception in the case of any errors:
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. |
It might throw an exception in the case of any errors:
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.
This is internal auxiliary function for checking that the recordset manager is initialized correctly.
| Name | Pass type | Value type | Default value | Description |
|---|---|---|---|---|
| $type | by value | string |
The type of validation - table or query. |
It might throw an exception in the case of any errors: