Index
A generic data provider
All the queries are "prepared" accordling to the data engine used. This means the parameters are modified by calling preparedName() and preparedValue() of the TIP_Data_Engine object.
Prepending the at symbol (@) to a name means that name must be passed-throught without modification (a raw name).
The data path
The data engine
The primary key field
Defaults to 'id' but can be changed passing a different 'primary_key' option. The primary key univoquely identifies a single row of data.
Fields to use in queries
An array of field ids used by this object. If left null, all the fields are assumed.
Join definitions
Check the options
Overridable static method that checks $options for missing or invalid values and eventually corrects its content.
Constructor
Initializes a TIP_Data instance.
$options inherits the TIP_Type properties, and add the following: * $options['path']: the path to the data source or the table name
Get the last id
Returns the last id as returned by the last call to putRow().
Get the reference of the $_fields internal property
Mainly used by the data engine to fill the fields structure.
Create a basic filter
Creates a filter (in the proper engine format) to access the rows that match the specified filter. If $condition is not specified, it defaults to '=' (equal).
Create an appendable filter expression
Creates a portion of a filter (in the proper engine format) that can be added to the main filter (generated throught the filter() method).
Create a basic order clause
Builds the order clause (in the proper engine format) to sort the rows using the specified field. This clause can be appended to a main filter.
Create a limit clause
Builds a limit clause (in the proper engine format).
Create a filter to access a single row
Shortcut to create a filter (in the proper engine format) to access only the first row with the primary key matching $value. Useful when the primary key is unique to access records by id.
Get the fields structure
Gets the field structure of this data context.
Get a field type
Gets the field type by updating the internal field structure and searching for $id. If it is not found, a recursive search is performed on the joined TIP_Data objects (if any).
Read one row
Retrieves the content of the row with the specified $id.
Read more rows
Gets the rows that satisfy the $filter conditions. The syntax of the filter is data engine dependent: no assumptions are made by the TIP_Data class. Whenever possible, use the filter() and rowFilter() to build a proper filter.
Insert a new row
Inserts a new row in the data source. If the insert() method returns an autoincrement value, it will be used as the primary key of $row.
If $row is an empty array, a new row with default values will be inserted without errors.
Also, this method is subject to the fieldset: if $fieldset is set, only the fields present in this subset will be inserted.
Instead, if the primary key is defined in $row, this function fails if a row with the same primary key exists.
Insert more rows
Multiple inserts rows in the data source.
This method, as its single row counterpart, is subject to the fieldset in the same way putRow() is.
The primary keys can be defined, but if someone of them is yet present in the data source, this function will fail.
Update one row
Updates $row. If $old_row is specified, the id of the row to update is get from the primary key of $old_row. If it does not exists (or $old_row is not used) the id will be the primary key of $row. If not found yet, the function will fail because does not know the id to update.
$old_row is used also as filter to remove matching field contents between $row and $old_row. This is done to allow a check between the old and new row content, trying to avoid the update operation.
Update more rows
Updates the rows that match the $filter conditions accordling to the $row array, which must be a collection of "fieldid => value" to change. The syntax of $filter is data engine dependent: no assumptions are made by the TIP_Data class. This also means the $filter parameter must be $filter.
This function must be used to update more than one row: this means $row must not have the primary key defined (a primary key is unique). To update only one row, use updateRow() instead.
Delete one row
Deletes the specified row. $row could be the row id or the row array to delete.
Delete more rows
Deletes the rows matching the $filter conditions. The syntax of $filter is data engine dependent: no assumptions are made by the TIP_Data class. This also means the $filter parameter must be prepared for the engine: use the prepare... primitives provided by the data engine.
Notice empty filter are rejected by the engine to avoid dropping the whole content of a table.