![]() |
Xataface
2.0alpha2
Xataface Application Framework
|
Encapsulates a row in a relationship. This may contain fields that span across multiple tables. It implements many of the same methods as the Dataface_Record. More...
Public Member Functions | |
| Dataface_RelatedRecord ($record, $relationshipName, $values=null) | |
| Creates new blank related record whith the specified base record and relationship name. | |
Utility Methods | |
Miscellaneous housekeeping functions. | |
| clearCache () | |
| Clears the cached values. This is used internally to clear calculated values when something is changed. | |
| & | toRecord ($tablename=null) |
| Produces a Dataface_Record object representing the portion of this related record that is stored in a particular table. | |
| toRecords () | |
| Returns an array of Dataface_Record objects that represent collectively this related record. | |
| & | getParent () |
| Gets reference to the parent record (base record). | |
| testCondition ($condition) | |
| Takes a boolean expression resembling an SQL where clause and evaluates it based on the values in this record. | |
| getActions ($params=array()) | |
| Returns actions associated with this record. | |
Transactions | |
Methods to deal with transactions and change tracking (so that we know what has changed since we loaded the data from the db). | |
| clearFlags () | |
| Clears the dirty flags to indicate the current state of the record is consistent with the database - or at least nothing needs to be saved. | |
| setFlag ($fieldname) | |
| Sets a flag on a field to indicate that it has changed and should be saved. | |
| clearFlag ($fieldname) | |
| Clears a flag on a field to indicate that it has no changes since loading. | |
| isDirty ($fieldname) | |
| Checks if a particular field has changed since we loaded it (i.e. it is dirty). | |
Accessing Field Data | |
Methods for getting and setting field/column values in the record. | |
| setMetaDataValue ($key, $value) | |
| Sets a meta data value for a field. | |
| getLength ($fieldname) | |
| Gets the length of a field's value (in bytes or characters). | |
| setValue ($fieldname, $value) | |
| Sets the value for a field of this related record. | |
| setValues ($values) | |
| Sets multiple values at once. | |
| getValue ($fieldname) | |
| Gets the value for a field. | |
| getValueAsString ($fieldname) | |
| Gets the string value of a given field. | |
| htmlValue ($fieldname) | |
| Gets a field value as HTML. | |
| getValuesAsStrings ($fields='') | |
| Gets the values stored in this table as an associative array. The values are all returned as strings. | |
| strvals ($fields='') | |
| strval ($fieldname, $index=0) | |
| stringValue ($fieldname) | |
| & | getValues ($columns=null, $excludeNulls=false) |
| Gets the values of this related record. | |
| & | values ($fields=null) |
| & | vals ($fields=null) |
| val ($fieldname) | |
| getAbsoluteValues ($excludeNulls=false, $includeAll=false) | |
| Gets the values of this related record except that the keys of the returned associative array are absolute column names rather than relative names as are returned in getValues(). | |
| getForeignKeyValues ($sql=null) | |
| Returns 2-Dimensional associative array of the values in this related record and in any join table. The output of this method is used to add and remove related records. | |
| getUnconstrainedFields ($sql=null) | |
| Gets a list of fields that are unconstrained (i.e. can be edited. This is helpful when building forms for this record. | |
| getConstrainedFields ($sql=null) | |
| Returns a list of fields in this related record that are constrained (i.e. cannot be changed. | |
| getUnconstrainedTables ($sql=null) | |
| Gets a list of the tables in this related record that are unconstrained. Unconstrained tables are ones that contain fields that are unconstrained. | |
| display ($fieldname) | |
| Returns a the value of a field in a meaningful state so that it can be displayed. | |
| preview ($fieldname, $index=0, $maxlength=255) | |
| Shows a short preview of field contents. Useful for text fields when we just want to see the first bit of the field. This will also strip all html tags out of the content. | |
| printValue ($fieldname) | |
| printval ($fieldname) | |
| q ($fieldname) | |
| qq ($fieldname) | |
Metadata | |
Methods to get descriptive information about this record. | |
| getId () | |
| Returns the Id of this related record object. The id is a string in a url format to uniquely identify this related record. The format is: tablename/relationshipname?parentkey1=val1&parentkey2=val2&relationshipname::key1=val2&relationshipname::key2=val3. | |
| getTitle () | |
| Gets the record title. This wraps the domain record's getTitle() method. | |
Form Handling | |
| validate ($fieldname, $value, &$params) | |
| Validates a value against a field name. Returns true if the value is a valid value to be stored in the field. | |
Saving | |
| save ($lang=null, $secure=false) | |
Permissions | |
Methods for checking permissions for this record. | |
| getPermissions ($params=array(), $table=null) | |
| checkPermission ($perm, $params=array()) | |
| Checks to see if the current user is granted the specified permission on this record. | |
Data Fields | |
| $secureDisplay = true | |
| Flag to indicate whether display methods like display() and htmlValue should be constrained by permissions. Default is true. boolean. | |
| $_record | |
| The base record of the relationship. Dataface_Record. | |
| $_relationshipName | |
| The name of the relationship. string. | |
| $_relationship | |
| Reference to the relationship. Dataface_Relationship. | |
Encapsulates a row in a relationship. This may contain fields that span across multiple tables. It implements many of the same methods as the Dataface_Record.
File: Dataface/RelatedRecord.php Author: Steve Hannah shannah@sfu.ca Created: October 2005
Description: Represents a record that is part of a relationship.
Related records will be most often encountered as the output of Dataface_Record::getRelatedRecordObjects() However you can construct your own objects and use the Dataface_IO::addRelatedRecord() or Dataface_IO::addExistingRelatedRecord() methods for adding your record to the relationship.
Getting related records from a Dataface_Record object.
Getting the Dataface_Record object that encapsulates the domain table of this relationship:
Definition at line 61 of file RelatedRecord.php.
| checkPermission | ( | $perm, | |
$params = array() |
|||
| ) |
Checks to see if the current user is granted the specified permission on this record.
This is essentially a wrapper for the domain record's checkPermission() method.
| string | $perm | The name of the permission to check. |
| array | $params | Optional parameters. See Dataface_Record::checkPermission() for details of what can be included in this parameter. |
Definition at line 1356 of file RelatedRecord.php.
| clearCache | ( | ) |
Clears the cached values. This is used internally to clear calculated values when something is changed.
Definition at line 210 of file RelatedRecord.php.
| clearFlag | ( | $fieldname | ) |
Clears a flag on a field to indicate that it has no changes since loading.
| string | $fieldname | The name of the field to mark "clean". |
Definition at line 399 of file RelatedRecord.php.
| clearFlags | ( | ) |
Clears the dirty flags to indicate the current state of the record is consistent with the database - or at least nothing needs to be saved.
Definition at line 379 of file RelatedRecord.php.
| Dataface_RelatedRecord | ( | $record, | |
| $relationshipName, | |||
$values = null |
|||
| ) |
Creates new blank related record whith the specified base record and relationship name.
| Dataface_Record | $record | Reference to Dataface_Record object to which this record is related. |
| string | $relationshipName | The name of the relationship of which this related record is a member. |
| array | $values | Associative array of values for this related record. |
Definition at line 146 of file RelatedRecord.php.
| display | ( | $fieldname | ) |
Returns a the value of a field in a meaningful state so that it can be displayed.
This method is similar to getValueAsString() except that this goes a step further and resolves references. For example, some fields may store an integer that represents the id for a related record in another table. If a vocabulary is assigned to that field that defines the meanings for the integers, then this method will return the resolved vocabulary rather than the integer itself.
| string | $fieldname | The name of the field whose value we wish to retrieve. |
Definition at line 899 of file RelatedRecord.php.
| getAbsoluteValues | ( | $excludeNulls = false, |
|
$includeAll = false |
|||
| ) |
Gets the values of this related record except that the keys of the returned associative array are absolute column names rather than relative names as are returned in getValues().
| boolean | $excludeNulls | If true then 'null' values are not included in returned associative array. |
Definition at line 742 of file RelatedRecord.php.
| getActions | ( | $params = array() | ) |
Returns actions associated with this record.
| array | $params | An associative array of parameters to filter the actions. Possible keys include: category => the name of a category of actions to return. |
Definition at line 353 of file RelatedRecord.php.
| getConstrainedFields | ( | $sql = null | ) |
Returns a list of fields in this related record that are constrained (i.e. cannot be changed.
Definition at line 848 of file RelatedRecord.php.
| getForeignKeyValues | ( | $sql = null | ) |
Returns 2-Dimensional associative array of the values in this related record and in any join table. The output of this method is used to add and remove related records.
| string | $sql | Optional SQL query that is used for getting the related records. |
Definition at line 772 of file RelatedRecord.php.
| getId | ( | ) |
Returns the Id of this related record object. The id is a string in a url format to uniquely identify this related record. The format is: tablename/relationshipname?parentkey1=val1&parentkey2=val2&relationshipname::key1=val2&relationshipname::key2=val3.
Definition at line 1033 of file RelatedRecord.php.
| getLength | ( | $fieldname | ) |
Gets the length of a field's value (in bytes or characters).
This will work for Blob fields as well as regular fields, as it is calculated using the MySQL LENGTH() function.
| string | $fieldname | The name of the field whose length we want to check. |
Definition at line 451 of file RelatedRecord.php.
| & getParent | ( | ) |
Gets reference to the parent record (base record).
The difference between this method and the toRecord() method is that this returns the parent record (or the source record of the relationship) - a record that generally is not part of this related record. The toRecord() method returns a record that comprises a portion of this related record (or at least the columns in one of the tables that is spanned by this related record).
For example:
Definition at line 316 of file RelatedRecord.php.
| getPermissions | ( | $params = array(), |
|
$table = null |
|||
| ) |
Definition at line 1185 of file RelatedRecord.php.
| getTitle | ( | ) |
Gets the record title. This wraps the domain record's getTitle() method.
Definition at line 1059 of file RelatedRecord.php.
| getUnconstrainedFields | ( | $sql = null | ) |
Gets a list of fields that are unconstrained (i.e. can be edited. This is helpful when building forms for this record.
Definition at line 794 of file RelatedRecord.php.
| getUnconstrainedTables | ( | $sql = null | ) |
Gets a list of the tables in this related record that are unconstrained. Unconstrained tables are ones that contain fields that are unconstrained.
Definition at line 861 of file RelatedRecord.php.
| getValue | ( | $fieldname | ) |
Gets the value for a field.
| string | $fieldname | The name of the field whose value we are retrieving. This may be either a relative fieldname or an absolute column name. |
Definition at line 531 of file RelatedRecord.php.
| getValueAsString | ( | $fieldname | ) |
Gets the string value of a given field.
| string | $fieldname | The name of the field whose value we are retrieving. |
Definition at line 573 of file RelatedRecord.php.
| & getValues | ( | $columns = null, |
|
$excludeNulls = false |
|||
| ) |
Gets the values of this related record.
| array(string) | $columns An optional array of columns to get. | |
| boolean | $excludeNulls | If this is true, then columns with 'null' values will not be included. Defaults to 'false' |
Definition at line 703 of file RelatedRecord.php.
| getValuesAsStrings | ( | $fields = '' | ) |
Gets the values stored in this table as an associative array. The values are all returned as strings.
| array | fields An optional array of field names to retrieve. |
Definition at line 657 of file RelatedRecord.php.
| htmlValue | ( | $fieldname | ) |
Gets a field value as HTML.
| string | $fieldname | The name of the field whose value we wish to retrieve. |
Definition at line 616 of file RelatedRecord.php.
| isDirty | ( | $fieldname | ) |
Checks if a particular field has changed since we loaded it (i.e. it is dirty).
| string | $fieldname | The name of the field that we want to know about. |
Definition at line 409 of file RelatedRecord.php.
| preview | ( | $fieldname, | |
$index = 0, |
|||
$maxlength = 255 |
|||
| ) |
Shows a short preview of field contents. Useful for text fields when we just want to see the first bit of the field. This will also strip all html tags out of the content.
| string | $fieldname | The name of the field to preview. |
| int | $index | In case of a related record which index in the relationship to get the record from. |
| int | $maxlength | The maximum length of the preview (in characters). |
Definition at line 951 of file RelatedRecord.php.
| printval | ( | $fieldname | ) |
| printValue | ( | $fieldname | ) |
| q | ( | $fieldname | ) |
| ( | $fieldname | ) |
Displays field contents and converts html special characters to entities.
| string | $fieldname | The name of the field to display. |
Definition at line 995 of file RelatedRecord.php.
| save | ( | $lang = null, |
|
$secure = false |
|||
| ) |
Definition at line 1162 of file RelatedRecord.php.
| setFlag | ( | $fieldname | ) |
Sets a flag on a field to indicate that it has changed and should be saved.
| string | $fieldname | The name of the field to mark "dirty". |
Definition at line 389 of file RelatedRecord.php.
| setMetaDataValue | ( | $key, | |
| $value | |||
| ) |
Sets a meta data value for a field.
| string | $key | The string metadata name. |
| mixed | $value | The value. |
Definition at line 434 of file RelatedRecord.php.
| setValue | ( | $fieldname, | |
| $value | |||
| ) |
Sets the value for a field of this related record.
| string | $fieldname | The name of the field to set. This may be a relative name or an absolute column name. |
| mixed | $value | The value to set this field to. |
Definition at line 472 of file RelatedRecord.php.
| setValues | ( | $values | ) |
Sets multiple values at once.
| array | $values | Associative array of values to set. array([Field name] -> [Field value]) |
Definition at line 508 of file RelatedRecord.php.
| stringValue | ( | $fieldname | ) |
| strval | ( | $fieldname, | |
$index = 0 |
|||
| ) |
| strvals | ( | $fields = '' | ) |
| testCondition | ( | $condition | ) |
Takes a boolean expression resembling an SQL where clause and evaluates it based on the values in this record.
Example:
| string | $condition | A PHP expression that evaluates to a boolean. |
Definition at line 337 of file RelatedRecord.php.
| & toRecord | ( | $tablename = null | ) |
Produces a Dataface_Record object representing the portion of this related record that is stored in a particular table.
| string | $tablename | The name of the table for which we wich to have a Dataface_Record object returned. |
Definition at line 224 of file RelatedRecord.php.
| toRecords | ( | ) |
Returns an array of Dataface_Record objects that represent collectively this related record.
Definition at line 281 of file RelatedRecord.php.
| val | ( | $fieldname | ) |
| validate | ( | $fieldname, | |
| $value, | |||
| & | $params | ||
| ) |
Validates a value against a field name. Returns true if the value is a valid value to be stored in the field.
This method will always return true. The Delegate class can be used to override this method. Use <fieldname>__validate(&$record, $value, &$message) to override this functionality.
| string | $fieldname | The name of the field that we are validating for. |
| mixed | $value | The value that we are checking. |
| array | &$params | An out parameter to store the validation message. |
Definition at line 1106 of file RelatedRecord.php.
| & vals | ( | $fields = null | ) |
| & values | ( | $fields = null | ) |
| $_record |
The base record of the relationship. Dataface_Record.
Definition at line 80 of file RelatedRecord.php.
| $_relationship |
Reference to the relationship. Dataface_Relationship.
Definition at line 92 of file RelatedRecord.php.
| $_relationshipName |
The name of the relationship. string.
Definition at line 86 of file RelatedRecord.php.
| $secureDisplay = true |
Flag to indicate whether display methods like display() and htmlValue should be constrained by permissions. Default is true. boolean.
Definition at line 70 of file RelatedRecord.php.
1.8.1.2